diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-10-29 12:20:30 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-11-01 07:58:06 (GMT) |
commit | 3efb8bf24fb66f2a9728ee511cf5767b5ed32903 (patch) | |
tree | 4be0e64dc5e86008e82dcc344a096cf75fd26b9a /tests/auto/qscriptvalue | |
parent | 121b7a47670f8a8e8e4c7ef6cf69a42865297158 (diff) | |
download | Qt-3efb8bf24fb66f2a9728ee511cf5767b5ed32903.zip Qt-3efb8bf24fb66f2a9728ee511cf5767b5ed32903.tar.gz Qt-3efb8bf24fb66f2a9728ee511cf5767b5ed32903.tar.bz2 |
Refactor tst_QScriptValue::isArray
The test should _data function. It should be easier to maintain that
code.
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptvalue')
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 30 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.h | 1 |
2 files changed, 22 insertions, 9 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index e5af792..eee2a6e 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -1635,17 +1635,29 @@ void tst_QScriptValue::instanceOf() QCOMPARE(obj.instanceOf(otherEngine.globalObject().property("Object")), false); } +void tst_QScriptValue::isArray_data() +{ + newEngine(); + + QTest::addColumn<QScriptValue>("value"); + QTest::addColumn<bool>("array"); + + QTest::newRow("[]") << engine->evaluate("[]") << true; + 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::isArray() { - QScriptEngine eng; - QVERIFY(eng.evaluate("[]").isArray()); - QVERIFY(!eng.evaluate("{}").isArray()); - QVERIFY(!eng.globalObject().isArray()); - QVERIFY(!QScriptValue().isArray()); - QVERIFY(!QScriptValue(123).isArray()); - QVERIFY(!QScriptValue(false).isArray()); - QVERIFY(!eng.nullValue().isArray()); - QVERIFY(!eng.undefinedValue().isArray()); + QFETCH(QScriptValue, value); + QFETCH(bool, array); + + QCOMPARE(value.isArray(), array); } void tst_QScriptValue::isDate() diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h index 7eb4f04..ad6ca8d 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.h +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h @@ -95,6 +95,7 @@ private slots: void toDateTime(); void toRegExp(); void instanceOf(); + void isArray_data(); void isArray(); void isDate(); void isError(); |