diff --git a/test/testlibrary.cpp b/test/testlibrary.cpp index a2052e8e6..ec9545ec7 100644 --- a/test/testlibrary.cpp +++ b/test/testlibrary.cpp @@ -17,8 +17,10 @@ */ #include "library.h" +#include "settings.h" #include "token.h" #include "tokenlist.h" +#include "tokenize.h" #include "testsuite.h" #include @@ -41,6 +43,7 @@ private: TEST_CASE(function_arg_valid); TEST_CASE(function_arg_minsize); TEST_CASE(function_namespace); + TEST_CASE(function_method); TEST_CASE(function_warn); TEST_CASE(memory); TEST_CASE(memory2); // define extra "free" allocation functions @@ -361,6 +364,37 @@ private: } } + void function_method() const { + const char xmldata[] = "\n" + "\n" + " \n" + " false\n" + " \n" + ""; + + Library library; + readLibrary(library, xmldata); + ASSERT(library.use.empty()); + ASSERT(library.leakignore.empty()); + ASSERT(library.argumentChecks.empty()); + + { + Settings settings; + Tokenizer tokenizer(&settings, nullptr); + std::istringstream istr("CString str; str.Format();"); + tokenizer.tokenize(istr, "test.cpp"); + ASSERT(library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format"))); + } + + { + Settings settings; + Tokenizer tokenizer(&settings, nullptr); + std::istringstream istr("HardDrive hd; hd.Format();"); + tokenizer.tokenize(istr, "test.cpp"); + ASSERT(!library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format"))); + } + } + void function_warn() const { const char xmldata[] = "\n" "\n"