diff options
author | renato <renato.filho@openbossa.org> | 2009-12-08 15:58:11 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-08 16:55:09 -0300 |
commit | 00a880f4d61a6a32f3e1dcaa4a692a6e430c123a (patch) | |
tree | cd720a51170898d35a2b384f3040ebd6f9b718f8 /tests | |
parent | 6d16532a7d504cd1fcd7553957e7e53beac7fc37 (diff) |
Fixed support for modify args in add-function tag.
Created tests.
Reviewed by Hugo Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testaddfunction.cpp | 34 | ||||
-rw-r--r-- | tests/testaddfunction.h | 3 |
2 files changed, 35 insertions, 2 deletions
diff --git a/tests/testaddfunction.cpp b/tests/testaddfunction.cpp index 113fbf47c..781736ba4 100644 --- a/tests/testaddfunction.cpp +++ b/tests/testaddfunction.cpp @@ -167,7 +167,7 @@ void TestAddFunction::testAddFunctionCodeSnippets() QVERIFY(addedFunc->hasInjectedCode()); } -void TestAddFunction::testFunctionWithoutParenteses() +void TestAddFunction::testAddFunctionWithoutParenteses() { const char sig1[] = "func"; AddedFunction f1(sig1, "void"); @@ -197,6 +197,38 @@ void TestAddFunction::testFunctionWithoutParenteses() } +void TestAddFunction::testAddFunctionWithDefaultArgs() +{ + const char sig1[] = "func"; + AddedFunction f1(sig1, "void"); + + QCOMPARE(f1.name(), QString("func")); + QCOMPARE(f1.arguments().count(), 0); + QCOMPARE(f1.isConstant(), false); + + const char cppCode[] = "struct A { };"; + const char xmlCode[] = "\ + <typesystem package=\"Foo\">\ + <primitive-type name='int'/> \ + <value-type name='A'>\ + <add-function signature='func(int, int)'>\ + <modify-argument index='2'>\ + <replace-default-expression with='2'/> \ + </modify-argument> \ + </add-function>\ + </value-type>\ + </typesystem>"; + + TestUtil t(cppCode, xmlCode, false); + AbstractMetaClassList classes = t.builder()->classes(); + AbstractMetaClass* classA = classes.findClass("A"); + QVERIFY(classA); + const AbstractMetaFunction* addedFunc = classA->findFunction("func"); + QVERIFY(addedFunc); + AbstractMetaArgument *arg = addedFunc->arguments()[1]; + QCOMPARE(arg->defaultValueExpression(), QString("2")); +} + QTEST_APPLESS_MAIN(TestAddFunction) #include "testaddfunction.moc" diff --git a/tests/testaddfunction.h b/tests/testaddfunction.h index 5600da7dc..98c0f83ba 100644 --- a/tests/testaddfunction.h +++ b/tests/testaddfunction.h @@ -34,7 +34,8 @@ private slots: void testAddFunctionConstructor(); void testAddFunctionTagDefaultValues(); void testAddFunctionCodeSnippets(); - void testFunctionWithoutParenteses(); + void testAddFunctionWithoutParenteses(); + void testAddFunctionWithDefaultArgs(); }; #endif |