MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / function_warn

Method function_warn

test/testlibrary.cpp:611–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609 }
610
611 void function_warn() const {
612 constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
613 "<def>\n"
614 " <function name=\"a\">\n"
615 " <warn severity=\"style\" cstd=\"c99\">Message</warn>\n"
616 " </function>\n"
617 " <function name=\"b\">\n"
618 " <warn severity=\"performance\" cppstd=\"c++11\" reason=\"Obsolescent\" alternatives=\"c,d,e\"/>\n"
619 " </function>\n"
620 "</def>";
621
622 Library library;
623 ASSERT(LibraryHelper::loadxmldata(library, xmldata, sizeof(xmldata)));
624
625 const char code[] = "a(); b();";
626 const SimpleTokenList tokenList(code);
627
628 const Library::WarnInfo* a = library.getWarnInfo(tokenList.front());
629 const Library::WarnInfo* b = library.getWarnInfo(tokenList.front()->tokAt(4));
630
631 ASSERT_EQUALS(2, library.functionwarn().size());
632 ASSERT(a && b);
633 if (a && b) {
634 ASSERT_EQUALS("Message", a->message);
635 ASSERT_EQUALS_ENUM(Severity::style, a->severity);
636 ASSERT_EQUALS(Standards::C99, a->standards.c);
637 ASSERT_EQUALS(Standards::CPP03, a->standards.cpp);
638
639 ASSERT_EQUALS("Obsolescent function 'b' called. It is recommended to use 'c', 'd' or 'e' instead.", b->message);
640 ASSERT_EQUALS_ENUM(Severity::performance, b->severity);
641 ASSERT_EQUALS(Standards::C89, b->standards.c);
642 ASSERT_EQUALS(Standards::CPP11, b->standards.cpp);
643 }
644 }
645
646 void memory() const {
647 constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"

Callers

nothing calls this directly

Calls 4

getWarnInfoMethod · 0.80
frontMethod · 0.80
tokAtMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected