Library: Fixed formatstr handling

This commit is contained in:
Daniel Marjamäki 2013-11-21 16:32:53 +01:00
parent b74db1b791
commit 2c1f579b3b
2 changed files with 32 additions and 2 deletions

View File

@ -115,9 +115,9 @@ bool Library::load(const tinyxml2::XMLDocument &doc)
else if (strcmp(argnode->Name(), "not-uninit") == 0) else if (strcmp(argnode->Name(), "not-uninit") == 0)
notuninit = true; notuninit = true;
else if (strcmp(argnode->Name(), "formatstr") == 0) else if (strcmp(argnode->Name(), "formatstr") == 0)
notuninit = true; formatstr = true;
else if (strcmp(argnode->Name(), "strz") == 0) else if (strcmp(argnode->Name(), "strz") == 0)
notuninit = true; strz = true;
else else
return false; return false;
} }

View File

@ -28,6 +28,7 @@ private:
void run() { void run() {
TEST_CASE(empty); TEST_CASE(empty);
TEST_CASE(function); TEST_CASE(function);
TEST_CASE(function_arg);
TEST_CASE(memory); TEST_CASE(memory);
} }
@ -61,6 +62,35 @@ private:
ASSERT(library.isnotnoreturn("foo")); ASSERT(library.isnotnoreturn("foo"));
} }
void function_arg() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\">\n"
" <not-uninit/>\n"
" </arg>\n"
" <arg nr=\"2\">\n"
" <not-null/>\n"
" </arg>\n"
" <arg nr=\"3\">\n"
" <formatstr/>\n"
" </arg>\n"
" <arg nr=\"4\">\n"
" <strz/>\n"
" </arg>\n"
" </function>\n"
"</def>";
tinyxml2::XMLDocument doc;
doc.Parse(xmldata, sizeof(xmldata));
Library library;
library.load(doc);
ASSERT_EQUALS(true, library.argumentChecks["foo"][1].notuninit);
ASSERT_EQUALS(true, library.argumentChecks["foo"][2].notnull);
ASSERT_EQUALS(true, library.argumentChecks["foo"][3].formatstr);
ASSERT_EQUALS(true, library.argumentChecks["foo"][4].strz);
}
void memory() { void memory() {
const char xmldata[] = "<?xml version=\"1.0\"?>\n" const char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n" "<def>\n"