diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-26 12:19:27 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-26 12:22:32 (GMT) |
commit | 1536b02ed1633555e306bec02398a2a7c1bdabf7 (patch) | |
tree | 81a10cb15161dbc6c0075a9ab6e44e2e1dcddcd6 /tests/auto | |
parent | 2c8348f5ccf62be31479dcd78282395a98eed76f (diff) | |
download | Qt-1536b02ed1633555e306bec02398a2a7c1bdabf7.zip Qt-1536b02ed1633555e306bec02398a2a7c1bdabf7.tar.gz Qt-1536b02ed1633555e306bec02398a2a7c1bdabf7.tar.bz2 |
Test for QDate::fromDate with string format.
Note that two digit years are always in the year 19xx
This is excepted for compatibility reason as discussed with Peter
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qdate/tst_qdate.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qdate/tst_qdate.cpp b/tests/auto/qdate/tst_qdate.cpp index d4273d0..4d6c80c 100644 --- a/tests/auto/qdate/tst_qdate.cpp +++ b/tests/auto/qdate/tst_qdate.cpp @@ -82,6 +82,8 @@ private slots: void operator_gt_eq(); void fromString_data(); void fromString(); + void fromString_format_data(); + void fromString_format(); void toString_format_data(); void toString_format(); void isLeapYear(); @@ -618,6 +620,30 @@ void tst_QDate::fromString() QCOMPARE( QDate::fromString( str2, Qt::ISODate ), d1 ); } +void tst_QDate::fromString_format_data() +{ + QTest::addColumn<QString>("string"); + QTest::addColumn<QString>("format"); + QTest::addColumn<QDate>("date"); + + //year with yy is always 19xx for compatibility + QTest::newRow( "data0" ) << QString("21052006") << QString("ddMMyyyy") << QDate(2006,5,21); + QTest::newRow( "data1" ) << QString("210506") << QString("ddMMyy") << QDate(1906,5,21); + QTest::newRow( "data2" ) << QString("21/5/2006") << QString("d/M/yyyy") << QDate(2006,5,21); + QTest::newRow( "data3" ) << QString("21/5/06") << QString("d/M/yy") << QDate(1906,5,21); + QTest::newRow( "data4" ) << QString("20060521") << QString("yyyyMMdd") << QDate(2006,5,21); + QTest::newRow( "data5" ) << QString("060521") << QString("yyMMdd") << QDate(1906,5,21); +} + +void tst_QDate::fromString_format() +{ + QFETCH( QString, string ); + QFETCH( QString, format ); + QFETCH( QDate, date ); + + QCOMPARE( QDate::fromString( string, format ), date ); +} + void tst_QDate::toString_format_data() { QTest::addColumn<QDate>("t"); |