@@ -53,11 +53,9 @@ class TestIO : public TestFixture {
5353 TEST_CASE (testMicrosoftCStringFormatArguments); // ticket #4920
5454 TEST_CASE (testMicrosoftSecurePrintfArgument);
5555 TEST_CASE (testMicrosoftSecureScanfArgument);
56-
57- TEST_CASE (testlibrarycfg); // library configuration
5856 }
5957
60- void check (const char code[], bool inconclusive = false , bool portability = false , Settings::PlatformType platform = Settings::Unspecified, Library *lib = NULL ) {
58+ void check (const char code[], bool inconclusive = false , bool portability = false , Settings::PlatformType platform = Settings::Unspecified) {
6159 // Clear the error buffer..
6260 errout.str (" " );
6361
@@ -69,8 +67,7 @@ class TestIO : public TestFixture {
6967 settings.inconclusive = inconclusive;
7068 settings.platform (platform);
7169
72- if (lib)
73- settings.library = *lib;
70+ settings.library = _lib;
7471
7572 // Tokenize..
7673 Tokenizer tokenizer (&settings, this );
@@ -437,6 +434,8 @@ class TestIO : public TestFixture {
437434
438435
439436 void testScanf1 () {
437+ LOAD_LIB (" std.cfg" );
438+
440439 check (" void foo() {\n "
441440 " int a, b;\n "
442441 " FILE *file = fopen(\" test\" , \" r\" );\n "
@@ -455,6 +454,8 @@ class TestIO : public TestFixture {
455454 }
456455
457456 void testScanf2 () {
457+ LOAD_LIB (" std.cfg" );
458+
458459 check (" void foo() {\n "
459460 " scanf(\" %5s\" , bar);\n " // Width specifier given
460461 " scanf(\" %5[^~]\" , bar);\n " // Width specifier given
@@ -481,6 +482,7 @@ class TestIO : public TestFixture {
481482 }
482483
483484 void testScanf4 () { // ticket #2553
485+ LOAD_LIB (" std.cfg" );
484486
485487 check (" void f()\n "
486488 " {\n "
@@ -494,6 +496,8 @@ class TestIO : public TestFixture {
494496
495497
496498 void testScanfArgument () {
499+ LOAD_LIB (" std.cfg" );
500+
497501 check (" void foo() {\n "
498502 " scanf(\" %1d\" , &foo);\n "
499503 " sscanf(bar, \" %1d\" , &foo);\n "
@@ -1322,6 +1326,7 @@ class TestIO : public TestFixture {
13221326 }
13231327
13241328 void testPrintfArgument () {
1329+ LOAD_LIB (" std.cfg" );
13251330 check (" void foo() {\n "
13261331 " printf(\" %u\" );\n "
13271332 " printf(\" %u%s\" , 123);\n "
@@ -2107,6 +2112,8 @@ class TestIO : public TestFixture {
21072112 }
21082113
21092114 void testPosixPrintfScanfParameterPosition () { // #4900 - No support for parameters in format strings
2115+ LOAD_LIB (" std.cfg" );
2116+
21102117 check (" void foo() {"
21112118 " int bar;"
21122119 " printf(\" %1$d\" , 1);"
@@ -2131,6 +2138,9 @@ class TestIO : public TestFixture {
21312138
21322139
21332140 void testMicrosoftPrintfArgument () {
2141+ LOAD_LIB (" std.cfg" );
2142+ LOAD_LIB (" windows.cfg" );
2143+
21342144 check (" void foo() {\n "
21352145 " size_t s;\n "
21362146 " ptrdiff_t p;\n "
@@ -2220,6 +2230,9 @@ class TestIO : public TestFixture {
22202230 }
22212231
22222232 void testMicrosoftScanfArgument () {
2233+ LOAD_LIB (" std.cfg" );
2234+ LOAD_LIB (" windows.cfg" );
2235+
22232236 check (" void foo() {\n "
22242237 " size_t s;\n "
22252238 " ptrdiff_t p;\n "
@@ -2324,6 +2337,9 @@ class TestIO : public TestFixture {
23242337 }
23252338
23262339 void testMicrosoftSecurePrintfArgument () {
2340+ LOAD_LIB (" std.cfg" );
2341+ LOAD_LIB (" windows.cfg" );
2342+
23272343 check (" void foo() {\n "
23282344 " int i;\n "
23292345 " unsigned int u;\n "
@@ -2514,6 +2530,8 @@ class TestIO : public TestFixture {
25142530 }
25152531
25162532 void testMicrosoftSecureScanfArgument () {
2533+ LOAD_LIB (" windows.cfg" );
2534+
25172535 check (" void foo() {\n "
25182536 " int i;\n "
25192537 " unsigned int u;\n "
@@ -2644,22 +2662,6 @@ class TestIO : public TestFixture {
26442662 " }\n " , false , false , Settings::Win32W);
26452663 ASSERT_EQUALS (" " , errout.str ());
26462664 }
2647-
2648- void testlibrarycfg () {
2649- const char code[] = " void f() {\n "
2650- " format(\" %s\" );\n "
2651- " }" ;
2652-
2653- // no error if configuration for 'format' is not provided
2654- check (code);
2655- ASSERT_EQUALS (" " , errout.str ());
2656-
2657- // error if configuration for 'format' is provided
2658- Library lib;
2659- lib.argumentChecks [" format" ][1 ].formatstr = true ;
2660- check (code, false , false , Settings::Unspecified, &lib);
2661- ASSERT_EQUALS (" [test.cpp:2]: (error) format format string requires 1 parameter but only 0 are given.\n " , errout.str ());
2662- }
26632665};
26642666
26652667REGISTER_TEST (TestIO)
0 commit comments