diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp
index 939c9406b..2d6b4ae34 100644
--- a/test/testerrorlogger.cpp
+++ b/test/testerrorlogger.cpp
@@ -384,6 +384,6 @@ private:
reportUnmatchedSuppressions(suppressions);
ASSERT_EQUALS("[a.c:10]: (information) Unmatched suppression: abc\n", errout.str());
}
-
};
+
REGISTER_TEST(TestErrorLogger)
diff --git a/test/testlibrary.cpp b/test/testlibrary.cpp
index 7aa6fb3c9..ec56b4049 100644
--- a/test/testlibrary.cpp
+++ b/test/testlibrary.cpp
@@ -48,13 +48,17 @@ private:
TEST_CASE(version);
}
+ Library::Error readLibrary(Library& library, const char* xmldata) const {
+ tinyxml2::XMLDocument doc;
+ doc.Parse(xmldata);
+ return library.load(doc);
+ }
+
void empty() const {
const char xmldata[] = "\n";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.use.empty());
ASSERT(library.leakignore.empty());
ASSERT(library.argumentChecks.empty());
@@ -67,8 +71,6 @@ private:
" false\n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
TokenList tokenList(nullptr);
std::istringstream istr("foo();");
@@ -76,7 +78,7 @@ private:
tokenList.front()->next()->astOperand1(tokenList.front());
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.use.empty());
ASSERT(library.leakignore.empty());
ASSERT(library.argumentChecks.empty());
@@ -90,16 +92,15 @@ private:
" "
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
+
+ Library library;
+ readLibrary(library, xmldata);
{
TokenList tokenList(nullptr);
std::istringstream istr("fred.foo(123);"); // <- wrong scope, not library function
tokenList.createTokens(istr);
- Library library;
- library.load(doc);
ASSERT(library.isNotLibraryFunction(tokenList.front()->tokAt(2)));
}
@@ -108,8 +109,6 @@ private:
std::istringstream istr("Fred::foo(123);"); // <- wrong scope, not library function
tokenList.createTokens(istr);
- Library library;
- library.load(doc);
ASSERT(library.isNotLibraryFunction(tokenList.front()->tokAt(2)));
}
}
@@ -121,8 +120,6 @@ private:
" "
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
TokenList tokenList(nullptr);
std::istringstream istr("foo();"); // <- too few arguments, not library function
@@ -130,7 +127,7 @@ private:
tokenList.front()->next()->astOperand1(tokenList.front());
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.isNotLibraryFunction(tokenList.front()));
}
@@ -141,8 +138,6 @@ private:
" "
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
TokenList tokenList(nullptr);
std::istringstream istr("Fred foo(123);"); // <- Variable declaration, not library function
@@ -151,7 +146,7 @@ private:
tokenList.front()->next()->varId(1);
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.isNotLibraryFunction(tokenList.front()->next()));
}
@@ -166,11 +161,9 @@ private:
" \n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT_EQUALS(true, library.argumentChecks["foo"][1].notuninit);
ASSERT_EQUALS(true, library.argumentChecks["foo"][2].notnull);
ASSERT_EQUALS(true, library.argumentChecks["foo"][3].formatstr);
@@ -185,11 +178,9 @@ private:
" \n"
"\n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT_EQUALS(true, library.argumentChecks["foo"][-1].notuninit);
}
@@ -204,11 +195,9 @@ private:
" :1,5\n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
TokenList tokenList(nullptr);
std::istringstream istr("foo(a,b,c,d,e);");
@@ -257,11 +246,9 @@ private:
" \n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
TokenList tokenList(nullptr);
std::istringstream istr("foo(a,b,c);");
@@ -296,11 +283,9 @@ private:
" false\n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.use.empty());
ASSERT(library.leakignore.empty());
ASSERT(library.argumentChecks.empty());
@@ -328,11 +313,9 @@ private:
" DeleteX\n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.use.empty());
ASSERT(library.leakignore.empty());
ASSERT(library.argumentChecks.empty());
@@ -372,11 +355,9 @@ private:
" DeleteX\n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
ASSERT(library.use.empty());
ASSERT(library.leakignore.empty());
ASSERT(library.argumentChecks.empty());
@@ -390,11 +371,8 @@ private:
"\n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
-
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
const struct Library::PodType *type = library.podtype("s16");
ASSERT_EQUALS(2U, type ? type->size : 0U);
@@ -432,11 +410,9 @@ private:
" \n"
" \n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
Library library;
- library.load(doc);
+ readLibrary(library, xmldata);
Library::Container& A = library.containers["A"];
Library::Container& B = library.containers["B"];
@@ -482,33 +458,24 @@ private:
const char xmldata [] = "\n"
"\n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
-
Library library;
- Library::Error err = library.load(doc);
+ Library::Error err = readLibrary(library, xmldata);
ASSERT_EQUALS(err.errorcode, Library::OK);
}
{
const char xmldata [] = "\n"
"\n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
-
Library library;
- Library::Error err = library.load(doc);
+ Library::Error err = readLibrary(library, xmldata);
ASSERT_EQUALS(err.errorcode, Library::OK);
}
{
const char xmldata [] = "\n"
"\n"
"";
- tinyxml2::XMLDocument doc;
- doc.Parse(xmldata, sizeof(xmldata));
-
Library library;
- Library::Error err = library.load(doc);
+ Library::Error err = readLibrary(library, xmldata);
ASSERT_EQUALS(err.errorcode, Library::UNSUPPORTED_FORMAT);
}
}