| 1 |
#include "Core/Season.h" |
| 2 |
|
| 3 |
#include <QTest> |
| 4 |
|
| 5 |
|
| 6 |
class TestSeasonOffset: public QObject |
| 7 |
{ |
| 8 |
Q_OBJECT |
| 9 |
|
| 10 |
private slots: |
| 11 |
void isValidFalse() { |
| 12 |
SeasonOffset offset; |
| 13 |
QCOMPARE(offset.isValid(), false); |
| 14 |
} |
| 15 |
|
| 16 |
void isValidTrue() { |
| 17 |
SeasonOffset offset(-1, 1, 1); |
| 18 |
QCOMPARE(offset.isValid(), true); |
| 19 |
} |
| 20 |
|
| 21 |
void significantItemInvalid() { |
| 22 |
SeasonOffset offset; |
| 23 |
std::pair<SeasonOffset::SeasonOffsetType, int> item = offset.getSignificantItem(); |
| 24 |
QCOMPARE(item.first, SeasonOffset::invalid); |
| 25 |
QCOMPARE(item.second, 0); |
| 26 |
} |
| 27 |
|
| 28 |
void significantItemYear() { |
| 29 |
SeasonOffset offset(-2, 1, 1); |
| 30 |
std::pair<SeasonOffset::SeasonOffsetType, int> item = offset.getSignificantItem(); |
| 31 |
QCOMPARE(item.first, SeasonOffset::year); |
| 32 |
QCOMPARE(item.second, -2); |
| 33 |
} |
| 34 |
|
| 35 |
void significantItemMonth() { |
| 36 |
SeasonOffset offset(1, -2, 1); |
| 37 |
std::pair<SeasonOffset::SeasonOffsetType, int> item = offset.getSignificantItem(); |
| 38 |
QCOMPARE(item.first, SeasonOffset::month); |
| 39 |
QCOMPARE(item.second, -2); |
| 40 |
} |
| 41 |
|
| 42 |
void significantItemWeek() { |
| 43 |
SeasonOffset offset(1, 1, -2); |
| 44 |
std::pair<SeasonOffset::SeasonOffsetType, int> item = offset.getSignificantItem(); |
| 45 |
QCOMPARE(item.first, SeasonOffset::week); |
| 46 |
QCOMPARE(item.second, -2); |
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
QTEST_MAIN(TestSeasonOffset) |
| 52 |
#include "testSeasonOffset.moc" |