From e7c1e8b82eaadfdbc1e8ead46fa2f3fe36e29f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 19 Aug 2016 10:47:44 +0200 Subject: [PATCH] TestLibrary: Added tests for method calls --- test/testlibrary.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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"