diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-10-29 13:07:05 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-11-01 07:58:26 (GMT) |
commit | 21a4759ba82212097a0d76dcf341b5e8e497d057 (patch) | |
tree | 298a611f779dd45e88b3d7a0c886e621d749a8bb /tests/auto | |
parent | 5a6c72fd39a9088e9066bb611790577f4cd8fd2f (diff) | |
download | Qt-21a4759ba82212097a0d76dcf341b5e8e497d057.zip Qt-21a4759ba82212097a0d76dcf341b5e8e497d057.tar.gz Qt-21a4759ba82212097a0d76dcf341b5e8e497d057.tar.bz2 |
Refactor tst_QScriptValue::isRegExp
The test should use _data function. It should be easier to maintain that
code.
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 32 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.h | 1 |
2 files changed, 23 insertions, 10 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 44318b4..47ff9d7 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -1711,18 +1711,30 @@ void tst_QScriptValue::isError() QVERIFY(!eng.evaluate("new Object()").isError()); } +void tst_QScriptValue::isRegExp_data() +{ + newEngine(); + + QTest::addColumn<QScriptValue>("value"); + QTest::addColumn<bool>("regexp"); + + QTest::newRow("/foo/") << engine->evaluate("/foo/") << 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::isRegExp() { - QScriptEngine eng; - QVERIFY(eng.evaluate("/foo/").isRegExp()); - QVERIFY(!eng.evaluate("[]").isRegExp()); - QVERIFY(!eng.evaluate("{}").isRegExp()); - QVERIFY(!eng.globalObject().isRegExp()); - QVERIFY(!QScriptValue().isRegExp()); - QVERIFY(!QScriptValue(123).isRegExp()); - QVERIFY(!QScriptValue(false).isRegExp()); - QVERIFY(!eng.nullValue().isRegExp()); - QVERIFY(!eng.undefinedValue().isRegExp()); + QFETCH(QScriptValue, value); + QFETCH(bool, regexp); + + QCOMPARE(value.isRegExp(), regexp); } static QScriptValue getter(QScriptContext *ctx, QScriptEngine *) diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h index 239f668..300ce61 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.h +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h @@ -100,6 +100,7 @@ private slots: void isDate(); void isDate_data(); void isError(); + void isRegExp_data(); void isRegExp(); void lessThan(); |