diff options
author | Alexander V. Wolf <alex.v.wolf@gmail.com> | 2022-01-08 20:14:00 +0700 |
---|---|---|
committer | Alexander V. Wolf <alex.v.wolf@gmail.com> | 2022-01-08 20:14:00 +0700 |
commit | 6fe2af8c91b1c999b08ec35a8b39f1972a4719aa (patch) | |
tree | 28c7d31ac01b7498a9243f712033d2a4c92ea371 | |
parent | d240bb5df871c321e38f0acf1b2f7121448f53fb (diff) |
Added unit tests + fixed error
-rw-r--r-- | src/core/StelUtils.cpp | 2 | ||||
-rw-r--r-- | src/tests/testDates.cpp | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/core/StelUtils.cpp b/src/core/StelUtils.cpp index be05aa20c0..fce2365875 100644 --- a/src/core/StelUtils.cpp +++ b/src/core/StelUtils.cpp @@ -670,7 +670,7 @@ QString julianDayToISO8601String(const double jd, bool addMS) if(addMS) { - res.append(".%1").arg(millis,3,10,QLatin1Char('0')); + res.append(QString(".%1").arg(millis,3,10,QLatin1Char('0'))); } if (year < 0) { diff --git a/src/tests/testDates.cpp b/src/tests/testDates.cpp index b2c75d2ee6..ae4c26b43b 100644 --- a/src/tests/testDates.cpp +++ b/src/tests/testDates.cpp @@ -89,6 +89,13 @@ void TestDates::dateRoundTrip() ok = qFuzzyCompare(i.key()+1.0, tmp+1.0); QVERIFY(ok); } + // check case: wrong format + double tmp = StelUtils::getJulianDayFromISO8601String("-9999-12-31 12:00:00", &ok); + QVERIFY(!ok); + ok = qFuzzyCompare(1.0, tmp+1.0); + QVERIFY(ok); + // check case: milliseconds + QCOMPARE(StelUtils::julianDayToISO8601String(2400000.0, true), "1858-11-16T12:00:00.000"); } @@ -152,6 +159,22 @@ void TestDates::testRolloverAndValidity() QVERIFY(12==dh); QVERIFY(0==dmin); QVERIFY(0==ds); + + QVERIFY2(StelUtils::changeDateTimeForRollover(2021, 13, 32, 24, 60, 60, &dy, &dm, &dd, &dh, &dmin, &ds), "2l"); + QVERIFY(2022==dy); + QVERIFY(2==dm); + QVERIFY(2==dd); + QVERIFY(1==dh); + QVERIFY(1==dmin); + QVERIFY(0==ds); + + QVERIFY2(StelUtils::changeDateTimeForRollover(2021, 1, -1, -1, -1, -1, &dy, &dm, &dd, &dh, &dmin, &ds), "3l"); + QVERIFY(2020==dy); + QVERIFY(12==dm); + QVERIFY(29==dd); + QVERIFY(22==dh); + QVERIFY(58==dmin); + QVERIFY(59==ds); } /* |