Add QDateTime support for QXlsx::Cell

This commit is contained in:
Debao Zhang
2013-10-25 15:23:03 +08:00
parent 1b5d22e3ee
commit 8faebaaa91
12 changed files with 215 additions and 16 deletions
+52
View File
@@ -0,0 +1,52 @@
#include "xlsxformat.h"
#include <QString>
#include <QtTest>
QTXLSX_USE_NAMESPACE
class FormatTest : public QObject
{
Q_OBJECT
public:
FormatTest();
private Q_SLOTS:
void testDateTimeFormat();
void testDateTimeFormat_data();
};
FormatTest::FormatTest()
{
}
void FormatTest::testDateTimeFormat()
{
QFETCH(QString, data);
QFETCH(bool, res);
Format fmt;
fmt.setNumberFormat(data);
QCOMPARE(fmt.isDateTimeFormat(), res);
}
void FormatTest::testDateTimeFormat_data()
{
QTest::addColumn<QString>("data");
QTest::addColumn<bool>("res");
QTest::newRow("0") << QString("yyyy-mm-dd")<<true;
QTest::newRow("1") << QString("m/d/yy")<<true;
QTest::newRow("2") << QString("h:mm AM/PM")<<true;
QTest::newRow("3") << QString("m/d/yy h:mm")<<true;
QTest::newRow("4") << QString("[h]:mm:ss")<<true;
QTest::newRow("5") << QString("[h]")<<true;
QTest::newRow("6") << QString("[m]")<<true;
QTest::newRow("20") << QString("[Red]#,##0 ;[Yellow](#,##0)")<<false;
}
QTEST_APPLESS_MAIN(FormatTest)
#include "tst_formattest.moc"