Skip to content

Commit dcd7aff

Browse files
committed
add library test
1 parent 2d320c8 commit dcd7aff

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/testlibrary.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class TestLibrary : public TestFixture {
5757
TEST_CASE(function_method);
5858
TEST_CASE(function_baseClassMethod); // calling method in base class
5959
TEST_CASE(function_warn);
60+
TEST_CASE(function_possible_null);
6061
TEST_CASE(memory);
6162
TEST_CASE(memory2); // define extra "free" allocation functions
6263
TEST_CASE(memory3);
@@ -643,6 +644,24 @@ class TestLibrary : public TestFixture {
643644
}
644645
}
645646

647+
void function_possible_null() const {
648+
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
649+
"<def>\n"
650+
" <function name=\"a\">\n"
651+
" <returnValue type=\"void *\" possible-null=\"true\"/>\n"
652+
" </function>\n"
653+
"</def>";
654+
655+
Library library;
656+
ASSERT(LibraryHelper::loadxmldata(library, xmldata, sizeof(xmldata)));
657+
658+
const char code[] = "a();\n";
659+
const SimpleTokenList tokenList(code);
660+
661+
const Library::Function *a = library.getFunction(tokenList.front());
662+
ASSERT(a->isPossibleNull);
663+
}
664+
646665
void memory() const {
647666
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
648667
"<def>\n"

0 commit comments

Comments
 (0)