summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-10-29 12:26:53 (GMT)
committerJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-11-01 07:58:16 (GMT)
commit5a6c72fd39a9088e9066bb611790577f4cd8fd2f (patch)
treec3a140163efb9cc1cad5b70d21b3c27f9a608ba9
parent3efb8bf24fb66f2a9728ee511cf5767b5ed32903 (diff)
downloadQt-5a6c72fd39a9088e9066bb611790577f4cd8fd2f.zip
Qt-5a6c72fd39a9088e9066bb611790577f4cd8fd2f.tar.gz
Qt-5a6c72fd39a9088e9066bb611790577f4cd8fd2f.tar.bz2
Refactor tst_QScriptValue::isDate
The test should use _data function. It should be easier to maintain that code. Reviewed-by: Kent Hansen
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp32
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.h1
2 files changed, 23 insertions, 10 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index eee2a6e..44318b4 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1660,18 +1660,30 @@ void tst_QScriptValue::isArray()
QCOMPARE(value.isArray(), array);
}
+void tst_QScriptValue::isDate_data()
+{
+ newEngine();
+
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("date");
+
+ QTest::newRow("date") << engine->evaluate("new Date()") << true;
+ QTest::newRow("[]") << engine->evaluate("[]") << false;
+ QTest::newRow("{}") << engine->evaluate("{}") << false;
+ QTest::newRow("globalObject") << engine->globalObject() << false;
+ QTest::newRow("invalid") << QScriptValue() << false;
+ QTest::newRow("number") << QScriptValue(123) << false;
+ QTest::newRow("bool") << QScriptValue(false) << false;
+ QTest::newRow("null") << engine->nullValue() << false;
+ QTest::newRow("undefined") << engine->undefinedValue() << false;
+}
+
void tst_QScriptValue::isDate()
{
- QScriptEngine eng;
- QVERIFY(eng.evaluate("new Date()").isDate());
- QVERIFY(!eng.evaluate("[]").isDate());
- QVERIFY(!eng.evaluate("{}").isDate());
- QVERIFY(!eng.globalObject().isDate());
- QVERIFY(!QScriptValue().isDate());
- QVERIFY(!QScriptValue(123).isDate());
- QVERIFY(!QScriptValue(false).isDate());
- QVERIFY(!eng.nullValue().isDate());
- QVERIFY(!eng.undefinedValue().isDate());
+ QFETCH(QScriptValue, value);
+ QFETCH(bool, date);
+
+ QCOMPARE(value.isDate(), date);
}
void tst_QScriptValue::isError()
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h
index ad6ca8d..239f668 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.h
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h
@@ -98,6 +98,7 @@ private slots:
void isArray_data();
void isArray();
void isDate();
+ void isDate_data();
void isError();
void isRegExp();