testdates.cpp   testdates.cpp 
#include <config.h> #include <config.h>
#include <QString> #include <QString>
#include <QDateTime> #include <QDateTime>
#include <QDate> #include <QDate>
#include <QtGlobal> #include <QtGlobal>
#include <QLocale> #include <QLocale>
#include <QtDebug> #include <QtDebug>
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "TextEntryDateTimeValidator.hpp"
using namespace std; using namespace std;
void _assert(bool b, QString msg = "") void _assert(bool b, QString msg = "")
{ {
if (!b) if (!b)
{ {
qFatal("FAILED: %s", qPrintable(msg)); qFatal("FAILED: %s", qPrintable(msg));
} }
} }
skipping to change at line 72 skipping to change at line 71
-334.0, -334.0,
-365.0, -365.0,
-699.0, -699.0,
-1064.0, -1064.0,
-1420.0, -1420.0,
-1785.0, -1785.0,
}; };
QString t1s[] = { QString t1s[] =
"-4712-01-01T12:00:00", {
"-4713-12-31T12:00:00", "-4712-01-01T12:00:00",
"2007-12-31T12:00:00", "-4713-12-31T12:00:00",
"2007-12-31T12:00:00",
"0000-01-01T12:00:00",
"2132-08-31T12:00:00", "0000-01-01T12:00:00",
"-4711-01-01T12:00:00", "2132-08-31T12:00:00",
"-4711-01-01T12:00:00",
"2008-03-08T12:00:00",
"1582-10-15T12:00:00", "2008-03-08T12:00:00",
"2008-01-01T00:00:00", "1582-10-15T12:00:00",
"2008-01-01T00:00:00",
"-0002-12-31T12:00:00",
"-0001-01-01T12:00:00", "-0002-12-31T12:00:00",
"1858-11-16T12:00:00", "-0001-01-01T12:00:00",
"1858-11-16T12:00:00",
"1066-04-12T12:00:00",
"0540-04-12T12:00:00", "1066-04-12T12:00:00",
"0201-04-12T12:00:00", "0540-04-12T12:00:00",
"0201-04-12T12:00:00",
"0099-04-12T12:00:00",
"0001-01-01T12:00:00", "0099-04-12T12:00:00",
"0002-01-01T12:00:00", "0001-01-01T12:00:00",
"0002-01-01T12:00:00",
"-4713-12-01T12:00:00",
"-4713-11-01T12:00:00", "-4713-12-01T12:00:00",
"-4713-10-01T12:00:00", "-4713-11-01T12:00:00",
"-4713-10-01T12:00:00",
"-4713-09-01T12:00:00",
"-4713-08-01T12:00:00", "-4713-09-01T12:00:00",
"-4713-07-01T12:00:00", "-4713-08-01T12:00:00",
"-4713-07-01T12:00:00",
"-4713-06-01T12:00:00",
"-4713-05-01T12:00:00", "-4713-06-01T12:00:00",
"-4713-04-01T12:00:00", "-4713-05-01T12:00:00",
"-4713-04-01T12:00:00",
"-4713-03-01T12:00:00",
"-4713-02-01T12:00:00", // 28 days "-4713-03-01T12:00:00",
"-4713-01-01T12:00:00", "-4713-02-01T12:00:00", // 28 days
"-4713-01-01T12:00:00",
"-4714-02-01T12:00:00", // 28 days
"-4715-02-01T12:00:00", // 28 days "-4714-02-01T12:00:00", // 28 days
"-4716-02-01T12:00:00", // 29 days "-4715-02-01T12:00:00", // 28 days
"-4716-02-01T12:00:00", // 29 days
"-4717-02-01T12:00:00", // 28 days "-4717-02-01T12:00:00", // 28 days
}; };
// does jdToIsoString() of item in t1d match string in t1s? // does jdToIsoString() of item in t1d match string in t1s?
vector<int> fromString; QList<int> fromString;
double jd; double jd;
bool success; bool success;
for (int i = 0; i < 31; i++) for (int i = 0; i < 31; i++)
{ {
_assert(QString::compare(StelUtils::jdToIsoString(t1d[i]), _assert(QString::compare(StelUtils::jdToIsoString(t1d[i]),
t1s[i]) == 0, t1s[i]) == 0,
QString("%1").arg(i) + ": " +StelUtils::jdToIsoStrin g(t1d[i]) + " ne " + t1s[i] + " (" + QDate::fromJulianDay((int)floor(t1d[i] )).toString() + ")"); QString("%1").arg(i) + ": " +StelUtils::jdToIsoStrin g(t1d[i]) + " ne " + t1s[i] + " (" + QDate::fromJulianDay((int)floor(t1d[i] )).toString() + ")");
fromString = TextEntryDateTimeValidator::getIntsFromISO8601S tring(t1s[i]); fromString = StelUtils::getIntsFromISO8601String(t1s[i]);
success = StelUtils::getJDFromDate( &jd, success = StelUtils::getJDFromDate( &jd,
fromString[0], fromString[0],
fromString[1], fromString[1],
fromString[2], fromString[2],
fromString[3], fromString[3],
fromString[4], fromString[4],
fromString[5] ); fromString[5] );
_assert(t1d[i] == jd && success, _assert(t1d[i] == jd && success,
QString("%1").arg(i) + ": " + QString("failed with " ) + t1s[i] + " " + QString("%1").arg(i) + ": " + QString("failed with " ) + t1s[i] + " " +
QString("%1").arg(jd, 10, 'f') + " vs " + QString("%1").arg(jd, 10, 'f') + " vs " +
 End of changes. 5 change blocks. 
49 lines changed or deleted 49 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/