@@ -740,16 +740,14 @@ class TestSuppressions : public TestFixture {
740740 }
741741
742742 void suppressingSyntaxErrors () { // syntaxErrors should be suppressible (#7076)
743- std::map<std::string, std::string> files;
744- files[" test.cpp" ] = " if if\n " ;
743+ const char code[] = " if if\n " ;
745744
746- ASSERT_EQUALS (0 , checkSuppression (files , " syntaxError:test.cpp:1" ));
745+ ASSERT_EQUALS (0 , checkSuppression (code , " syntaxError:test.cpp:1" ));
747746 ASSERT_EQUALS (" " , errout.str ());
748747 }
749748
750749 void suppressingSyntaxErrorsInline () { // syntaxErrors should be suppressible (#5917)
751- std::map<std::string, std::string> files;
752- files[" test.cpp" ] = " double result(0.0);\n "
750+ const char code[] = " double result(0.0);\n "
753751 " _asm\n "
754752 " {\n "
755753 " // cppcheck-suppress syntaxError\n "
@@ -759,13 +757,12 @@ class TestSuppressions : public TestFixture {
759757 " fstp QWORD PTR result ; store a double (8 bytes)\n "
760758 " pop EAX ; restore EAX\n "
761759 " }" ;
762- ASSERT_EQUALS (0 , checkSuppression (files , " " ));
760+ ASSERT_EQUALS (0 , checkSuppression (code , " " ));
763761 ASSERT_EQUALS (" " , errout.str ());
764762 }
765763
766764 void suppressingSyntaxErrorsWhileFileRead () { // syntaxError while file read should be suppressible (PR #1333)
767- std::map<std::string, std::string> files;
768- files[" test.cpp" ] = " CONST (genType, KS_CONST) genService[KS_CFG_NR_OF_NVM_BLOCKS] =\n "
765+ const char code[] = " CONST (genType, KS_CONST) genService[KS_CFG_NR_OF_NVM_BLOCKS] =\n "
769766 " {\n "
770767 " [!VAR \" BC\" = \" $BC + 1\" !][!//\n "
771768 " [!IF \" (as:modconf('Ks')[1]/KsGeneral/KsType = 'KS_CFG_TYPE_KS_MASTER') and\n "
@@ -778,7 +775,7 @@ class TestSuppressions : public TestFixture {
778775 " [!VAR \" BC\" = \" $BC + 1\" !][!//\n "
779776 " [!ENDIF!][!//\n "
780777 " };" ;
781- ASSERT_EQUALS (0 , checkSuppression (files , " syntaxError:test.cpp:4" ));
778+ ASSERT_EQUALS (0 , checkSuppression (code , " syntaxError:test.cpp:4" ));
782779 ASSERT_EQUALS (" " , errout.str ());
783780 }
784781
@@ -808,10 +805,9 @@ class TestSuppressions : public TestFixture {
808805 }
809806
810807 void suppressingSyntaxErrorAndExitCode () {
811- std::map<std::string, std::string> files;
812- files[" test.cpp" ] = " fi if;" ;
808+ const char code[] = " fi if;" ;
813809
814- ASSERT_EQUALS (0 , checkSuppression (files , " *:test.cpp" ));
810+ ASSERT_EQUALS (0 , checkSuppression (code , " *:test.cpp" ));
815811 ASSERT_EQUALS (" " , errout.str ());
816812
817813 // multi files, but only suppression one
@@ -822,20 +818,18 @@ class TestSuppressions : public TestFixture {
822818 ASSERT_EQUALS (" [test2.cpp:1]: (error) syntax error\n " , errout.str ());
823819
824820 // multi error in file, but only suppression one error
825- std::map<std::string, std::string> file2;
826- file2[" test.cpp" ] = " fi fi\n "
827- " if if;" ;
828- ASSERT_EQUALS (1 , checkSuppression (file2, " *:test.cpp:1" )); // suppress all error at line 1 of test.cpp
821+ const char code2[] = " fi fi\n "
822+ " if if;" ;
823+ ASSERT_EQUALS (1 , checkSuppression (code2, " *:test.cpp:1" )); // suppress all error at line 1 of test.cpp
829824 ASSERT_EQUALS (" [test.cpp:2]: (error) syntax error\n " , errout.str ());
830825
831826 // multi error in file, but only suppression one error (2)
832- std::map<std::string, std::string> file3;
833- file3[" test.cpp" ] = " void f(int x, int y){\n "
834- " int a = x/0;\n "
835- " int b = y/0;\n "
836- " }\n "
837- " f(0, 1);\n " ;
838- ASSERT_EQUALS (1 , checkSuppression (file3, " zerodiv:test.cpp:3" )); // suppress 'errordiv' at line 3 of test.cpp
827+ const char code3[] = " void f(int x, int y){\n "
828+ " int a = x/0;\n "
829+ " int b = y/0;\n "
830+ " }\n "
831+ " f(0, 1);\n " ;
832+ ASSERT_EQUALS (1 , checkSuppression (code3, " zerodiv:test.cpp:3" )); // suppress 'errordiv' at line 3 of test.cpp
839833 }
840834
841835};
0 commit comments