TestLibrary: Added tests for method calls

This commit is contained in:
Daniel Marjamäki 2016-08-19 10:47:44 +02:00
parent f555abb0b5
commit e7c1e8b82e
1 changed files with 34 additions and 0 deletions

View File

@ -17,8 +17,10 @@
*/ */
#include "library.h" #include "library.h"
#include "settings.h"
#include "token.h" #include "token.h"
#include "tokenlist.h" #include "tokenlist.h"
#include "tokenize.h"
#include "testsuite.h" #include "testsuite.h"
#include <tinyxml2.h> #include <tinyxml2.h>
@ -41,6 +43,7 @@ private:
TEST_CASE(function_arg_valid); TEST_CASE(function_arg_valid);
TEST_CASE(function_arg_minsize); TEST_CASE(function_arg_minsize);
TEST_CASE(function_namespace); TEST_CASE(function_namespace);
TEST_CASE(function_method);
TEST_CASE(function_warn); TEST_CASE(function_warn);
TEST_CASE(memory); TEST_CASE(memory);
TEST_CASE(memory2); // define extra "free" allocation functions TEST_CASE(memory2); // define extra "free" allocation functions
@ -361,6 +364,37 @@ private:
} }
} }
void function_method() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"CString::Format\">\n"
" <noreturn>false</noreturn>\n"
" </function>\n"
"</def>";
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 { void function_warn() const {
const char xmldata[] = "<?xml version=\"1.0\"?>\n" const char xmldata[] = "<?xml version=\"1.0\"?>\n"
"<def>\n" "<def>\n"