Skip to content

Commit e7c1e8b

Browse files
committed
TestLibrary: Added tests for method calls
1 parent f555abb commit e7c1e8b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/testlibrary.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
*/
1818

1919
#include "library.h"
20+
#include "settings.h"
2021
#include "token.h"
2122
#include "tokenlist.h"
23+
#include "tokenize.h"
2224
#include "testsuite.h"
2325
#include <tinyxml2.h>
2426

@@ -41,6 +43,7 @@ class TestLibrary : public TestFixture {
4143
TEST_CASE(function_arg_valid);
4244
TEST_CASE(function_arg_minsize);
4345
TEST_CASE(function_namespace);
46+
TEST_CASE(function_method);
4447
TEST_CASE(function_warn);
4548
TEST_CASE(memory);
4649
TEST_CASE(memory2); // define extra "free" allocation functions
@@ -361,6 +364,37 @@ class TestLibrary : public TestFixture {
361364
}
362365
}
363366

367+
void function_method() const {
368+
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
369+
"<def>\n"
370+
" <function name=\"CString::Format\">\n"
371+
" <noreturn>false</noreturn>\n"
372+
" </function>\n"
373+
"</def>";
374+
375+
Library library;
376+
readLibrary(library, xmldata);
377+
ASSERT(library.use.empty());
378+
ASSERT(library.leakignore.empty());
379+
ASSERT(library.argumentChecks.empty());
380+
381+
{
382+
Settings settings;
383+
Tokenizer tokenizer(&settings, nullptr);
384+
std::istringstream istr("CString str; str.Format();");
385+
tokenizer.tokenize(istr, "test.cpp");
386+
ASSERT(library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format")));
387+
}
388+
389+
{
390+
Settings settings;
391+
Tokenizer tokenizer(&settings, nullptr);
392+
std::istringstream istr("HardDrive hd; hd.Format();");
393+
tokenizer.tokenize(istr, "test.cpp");
394+
ASSERT(!library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format")));
395+
}
396+
}
397+
364398
void function_warn() const {
365399
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
366400
"<def>\n"

0 commit comments

Comments
 (0)