File: eastertest.cpp

package info (click to toggle)
kopeninghours 25.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 940 kB
  • sloc: cpp: 3,918; yacc: 795; lex: 335; python: 18; sh: 17; makefile: 16
file content (42 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
    SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include <../src/lib/easter.cpp>

#include <QTest>

using namespace KOpeningHours;

class EasterTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void testEaster_data()
    {
        QTest::addColumn<int>("year");
        QTest::addColumn<QDate>("date");

        QTest::newRow("2001") << 2001 << QDate(2001, 4, 15);
        QTest::newRow("2020") << 2020 << QDate(2020, 4, 12);
        QTest::newRow("2021") << 2021 << QDate(2021, 4, 4);
        QTest::newRow("2022") << 2022 << QDate(2022, 4, 17);
        QTest::newRow("2023") << 2023 << QDate(2023, 4, 9);
        QTest::newRow("2024") << 2024 << QDate(2024, 3, 31);
        QTest::newRow("2025") << 2025 << QDate(2025, 4, 20);
    }

    void testEaster()
    {
        QFETCH(int, year);
        QFETCH(QDate, date);
        QCOMPARE(Easter::easterDate(year), date);
        QCOMPARE(date.dayOfWeek(), 7);
    }
};

QTEST_GUILESS_MAIN(EasterTest)

#include "eastertest.moc"