testDates.cpp   testDates.cpp 
skipping to change at line 75 skipping to change at line 75
QVERIFY(ok); QVERIFY(ok);
if (i.key()!=0.0) if (i.key()!=0.0)
qFuzzyCompare(i.key(), tmp); qFuzzyCompare(i.key(), tmp);
else else
qFuzzyCompare(i.key()+1.0, tmp+1.0); qFuzzyCompare(i.key()+1.0, tmp+1.0);
} }
} }
void TestDates::formatting() void TestDates::formatting()
{ {
QLocale usEN;
// test formatting of StelUtils::localeDateString, the fall-back if QDateTime cannot do it. // test formatting of StelUtils::localeDateString, the fall-back if QDateTime cannot do it.
QLocale::setDefault(QLocale::German); QLocale::setDefault(QLocale::German);
QVERIFY2(QString::compare(StelUtils::localeDateString(2008, 03, 10, 0), QString("10.03.08")) == 0, QVERIFY2(QString::compare(StelUtils::localeDateString(2008, 03, 10, 0), QString("10.03.08")) == 0,
qPrintable("german for 2008-03-10 wrong: " + (StelU tils::localeDateString(2008, 03, 10, 0)))); qPrintable("german for 2008-03-10 wrong: " + (StelU tils::localeDateString(2008, 03, 10, 0))));
QVERIFY2(QString::compare(StelUtils::localeDateString(8, 03, 10, 0), QString("10.03.08")) == 0, QVERIFY2(QString::compare(StelUtils::localeDateString(8, 03, 10, 0), QString("10.03.08")) == 0,
qPrintable("german for 8-03-10 wrong: " + (StelUtil s::localeDateString(8, 03, 10, 0)))); qPrintable("german for 8-03-10 wrong: " + (StelUtil s::localeDateString(8, 03, 10, 0))));
QVERIFY2(QString::compare(StelUtils::localeDateString(-8, 03, 10, 0) , QString("10.03.-8")) == 0, QVERIFY2(QString::compare(StelUtils::localeDateString(-8, 03, 10, 0) , QString("10.03.-8")) == 0,
qPrintable("german for -8-03-10 wrong: " + (StelUti ls::localeDateString(-8, 03, 10, 0)))); qPrintable("german for -8-03-10 wrong: " + (StelUti ls::localeDateString(-8, 03, 10, 0))));
QVERIFY2(QString::compare(StelUtils::localeDateString(-1118, 03, 10, 0), QString("10.03.-18")) == 0, QVERIFY2(QString::compare(StelUtils::localeDateString(-1118, 03, 10, 0), QString("10.03.-18")) == 0,
qPrintable("german for -1118-03-10 wrong: " + (Stel Utils::localeDateString(-1118, 03, 10, 0)))); qPrintable("german for -1118-03-10 wrong: " + (Stel Utils::localeDateString(-1118, 03, 10, 0))));
QVERIFY2(QString::compare(StelUtils::localeDateString(-5118, 03, 10, 0), QString("10.03.-18")) == 0, QVERIFY2(QString::compare(StelUtils::localeDateString(-5118, 03, 10, 0), QString("10.03.-18")) == 0,
qPrintable("german for -5118-03-10 wrong: " + (Stel Utils::localeDateString(-5118, 03, 10, 0)))); qPrintable("german for -5118-03-10 wrong: " + (Stel Utils::localeDateString(-5118, 03, 10, 0))));
QVERIFY2(-18 == (-5118 % 100), qPrintable("modulus arithmetic works diff: " + QString("%1").arg(-5118 % 100))); QVERIFY2(-18 == (-5118 % 100), qPrintable("modulus arithmetic works diff: " + QString("%1").arg(-5118 % 100)));
// test arbitrary fmt // test arbitrary fmt
QLocale::setDefault(usEN); // This is useless, as StelUtils::localeDateString() formats dates
// according to the *system* locale. On systems where it is not Engl
QString easyLong("d dd ddd dddd M MM MMM MMMM yy yyyy"); ish,
QVERIFY2(QString::compare(QString("9 09 Sun Sunday 3 03 Mar March 08 // this test fails.
2008"), StelUtils::localeDateString(2008, 3, 9, 6, easyLong)) == 0, // See https://bugreports.qt-project.org/browse/QTBUG-27789. --BM
qPrintable("formatter1 not working: " + StelUtils:: // QLocale::setDefault(QLocale::English);
localeDateString(2008, 3, 9, 6, easyLong)));
QString hardLong("dddddddd '''doh' ''yyyyyyy"); // QString easyLong("d dd ddd dddd M MM MMM MMMM yy yyyy");
QVERIFY2(QString::compare(QString("SundaySunday 'doh '200808y"), Ste // QVERIFY2(QString::compare(QString("9 09 Sun Sunday 3 03 Mar March 08
lUtils::localeDateString(2008, 3, 9, 6, hardLong)) == 0, 2008"), StelUtils::localeDateString(2008, 3, 9, 6, easyLong)) == 0,
qPrintable("formatter2 not working: " + StelUtils:: // qPrintable("formatter1 not working: " + StelUtils::
localeDateString(2008, 3, 9, 6, hardLong))); localeDateString(2008, 3, 9, 6, easyLong)));
// QString hardLong("dddddddd '''doh' ''yyyyyyy");
// QVERIFY2(QString::compare(QString("SundaySunday 'doh '200808y"), Ste
lUtils::localeDateString(2008, 3, 9, 6, hardLong)) == 0,
// qPrintable("formatter2 not working: " + StelUtils::
localeDateString(2008, 3, 9, 6, hardLong)));
// test detection of offset from UTC. // test detection of offset from UTC.
double mar122008 = QDate(2008,3,12).toJulianDay(); double mar122008 = QDate(2008,3,12).toJulianDay();
qFuzzyCompare(StelUtils::getGMTShiftFromQT(mar122008), -4.f); qFuzzyCompare(StelUtils::getGMTShiftFromQT(mar122008), -4.f);
double mar012008 = QDate(2008,3,1).toJulianDay(); double mar012008 = QDate(2008,3,1).toJulianDay();
qFuzzyCompare(StelUtils::getGMTShiftFromQT(mar012008), -5.f); qFuzzyCompare(StelUtils::getGMTShiftFromQT(mar012008), -5.f);
} }
void TestDates::testRolloverAndValidity() void TestDates::testRolloverAndValidity()
 End of changes. 2 change blocks. 
14 lines changed or deleted 17 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/