diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-11-11 10:38:01 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-11-11 11:23:13 +0100 |
commit | 079e7a500fe2375986998774ee7ad5cb6ce7d86e (patch) | |
tree | a174bb8f1d7452a04f3f4e9aea72412f14b91a7e | |
parent | a7763fcfcb39343f71c2ee24a1d28268dfd11b26 (diff) |
C++: Tests: Make document_functionAt data driven
Change-Id: I8e811b21c584e7b6a2b8eb61830cb680f6fefa95
Reviewed-by: hjk <hjk121@nokiamail.com>
-rw-r--r-- | tests/auto/cplusplus/lookup/tst_lookup.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tests/auto/cplusplus/lookup/tst_lookup.cpp b/tests/auto/cplusplus/lookup/tst_lookup.cpp index 98fde5e216..10275002a3 100644 --- a/tests/auto/cplusplus/lookup/tst_lookup.cpp +++ b/tests/auto/cplusplus/lookup/tst_lookup.cpp @@ -86,9 +86,11 @@ class tst_Lookup: public QObject { Q_OBJECT -private Q_SLOTS: +private slots: void base_class_defined_1(); - void document_functionAt_1(); + + void document_functionAt_data(); + void document_functionAt(); // Objective-C void simple_class_1(); @@ -155,8 +157,13 @@ void tst_Lookup::base_class_defined_1() QVERIFY(classToAST.value(derivedClass) != 0); } -void tst_Lookup::document_functionAt_1() +void tst_Lookup::document_functionAt_data() { + QTest::addColumn<QByteArray>("source"); + QTest::addColumn<int>("line"); + QTest::addColumn<int>("column"); + QTest::addColumn<QString>("expectedFunction"); + const QByteArray source = "\n" "void Foo::Bar() {\n" // line 1 " \n" // line 2 @@ -164,19 +171,29 @@ void tst_Lookup::document_functionAt_1() " \n" // line 4 " }\n" "}\n"; // line 7 + const QString expectedFunction = QString::fromLatin1("Foo::Bar"); + QTest::newRow("nonInline1") << source << 1 << 2 << QString(); + QTest::newRow("nonInline2") << source << 1 << 11 << expectedFunction; + QTest::newRow("nonInline3") << source << 2 << 2 << expectedFunction; + QTest::newRow("nonInline4") << source << 3 << 10 << expectedFunction; + QTest::newRow("nonInline5") << source << 4 << 3 << expectedFunction; + QTest::newRow("nonInline6") << source << 6 << 1 << expectedFunction; +} + +void tst_Lookup::document_functionAt() +{ + QFETCH(QByteArray, source); + QFETCH(int, line); + QFETCH(int, column); + QFETCH(QString, expectedFunction); - Document::Ptr doc = Document::create("document_functionAt_1"); + Document::Ptr doc = Document::create("document_functionAt"); doc->setUtf8Source(source); doc->parse(); doc->check(); QVERIFY(doc->diagnosticMessages().isEmpty()); - QCOMPARE(doc->functionAt(1, 2), QString()); - QCOMPARE(doc->functionAt(1, 11), QString::fromLatin1("Foo::Bar")); - QCOMPARE(doc->functionAt(2, 2), QString::fromLatin1("Foo::Bar")); - QCOMPARE(doc->functionAt(3, 10), QString::fromLatin1("Foo::Bar")); - QCOMPARE(doc->functionAt(4, 3), QString::fromLatin1("Foo::Bar")); - QCOMPARE(doc->functionAt(6, 1), QString::fromLatin1("Foo::Bar")); + QCOMPARE(doc->functionAt(line, column), expectedFunction); } void tst_Lookup::simple_class_1() |