@@ -48,9 +48,11 @@ class TestIO : public TestFixture {
4848 TEST_CASE (testPrintfArgument);
4949
5050 TEST_CASE (testMicrosoftPrintfArgument); // ticket #4902
51+
52+ TEST_CASE (testlibrarycfg); // library configuration
5153 }
5254
53- void check (const char code[], bool inconclusive = false , bool portability = false , Settings::PlatformType platform = Settings::Unspecified) {
55+ void check (const char code[], bool inconclusive = false , bool portability = false , Settings::PlatformType platform = Settings::Unspecified, Library *lib = NULL ) {
5456 // Clear the error buffer..
5557 errout.str (" " );
5658
@@ -62,6 +64,9 @@ class TestIO : public TestFixture {
6264 settings.inconclusive = inconclusive;
6365 settings.platform (platform);
6466
67+ if (lib)
68+ settings.library = *lib;
69+
6570 // Tokenize..
6671 Tokenizer tokenizer (&settings, this );
6772 std::istringstream istr (code);
@@ -797,6 +802,22 @@ class TestIO : public TestFixture {
797802 " [test.cpp:12]: (warning) %I64u in format string (no. 2) requires an unsigned integer given in the argument list.\n "
798803 " [test.cpp:13]: (warning) %I64d in format string (no. 1) requires a signed integer given in the argument list.\n " , errout.str ());
799804 }
805+
806+ void testlibrarycfg () {
807+ const char code[] = " void f() {\n "
808+ " format(\" %s\" );\n "
809+ " }" ;
810+
811+ // no error if configuration for 'format' is not provided
812+ check (code);
813+ ASSERT_EQUALS (" " , errout.str ());
814+
815+ // error if configuration for 'format' is provided
816+ Library lib;
817+ lib.argumentChecks [" format" ][1 ].formatstr = true ;
818+ check (code, false , false , Settings::Unspecified, &lib);
819+ ASSERT_EQUALS (" [test.cpp:2]: (error) format format string has 1 parameters but only 0 are given.\n " , errout.str ());
820+ }
800821};
801822
802823REGISTER_TEST (TestIO)
0 commit comments