@@ -333,6 +333,9 @@ class TestPreprocessor : public TestFixture {
333333 TEST_CASE (getConfigsU5);
334334 TEST_CASE (getConfigsU6);
335335 TEST_CASE (getConfigsU7);
336+ TEST_CASE (getConfigsIssue14317);
337+
338+ TEST_CASE (getCodeIssue14317);
336339
337340 TEST_CASE (if_sizeof);
338341
@@ -435,7 +438,7 @@ class TestPreprocessor : public TestFixture {
435438 " #else\n "
436439 " #error abcd\n "
437440 " #endif\n " ;
438- ASSERT_EQUALS (" \n A\n " , getConfigsStr (filedata));
441+ ASSERT_EQUALS (" \n A=A \n " , getConfigsStr (filedata));
439442 }
440443
441444 void error2 () {
@@ -495,7 +498,7 @@ class TestPreprocessor : public TestFixture {
495498 " #else\n "
496499 " #error 2\n "
497500 " #endif\n " ;
498- ASSERT_EQUALS (" \n A\n A;B \n B\n " , getConfigsStr (filedata1));
501+ ASSERT_EQUALS (" \n A=A \n A=A;B=B \n B=B \n " , getConfigsStr (filedata1));
499502
500503 const char filedata2[] = " #ifndef A\n "
501504 " #error 1\n "
@@ -527,7 +530,7 @@ class TestPreprocessor : public TestFixture {
527530 " #else\n "
528531 " #error \" 2\"\n "
529532 " #endif\n " ;
530- ASSERT_EQUALS (" \n B\n " , getConfigsStr (filedata));
533+ ASSERT_EQUALS (" \n B=B \n " , getConfigsStr (filedata));
531534 }
532535
533536 void error8 () {
@@ -540,7 +543,7 @@ class TestPreprocessor : public TestFixture {
540543 " #ifndef C\n "
541544 " #error aa\n "
542545 " #endif" ;
543- ASSERT_EQUALS (" A;B ;C\n A;C\n C\n " , getConfigsStr (filedata));
546+ ASSERT_EQUALS (" A=A;B=B ;C\n A=A ;C\n C\n " , getConfigsStr (filedata));
544547 }
545548
546549 void setPlatformInfo () {
@@ -581,7 +584,7 @@ class TestPreprocessor : public TestFixture {
581584 " #endfile\n "
582585 " #ifdef ABC\n "
583586 " #endif" ;
584- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
587+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
585588 }
586589
587590 void includeguard2 () {
@@ -592,7 +595,7 @@ class TestPreprocessor : public TestFixture {
592595 " \n "
593596 " #endif\n "
594597 " #endfile\n " ;
595- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
598+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
596599 }
597600
598601
@@ -611,7 +614,7 @@ class TestPreprocessor : public TestFixture {
611614 // Expected configurations: "" and "ABC"
612615 ASSERT_EQUALS (2 , actual.size ());
613616 ASSERT_EQUALS (" \n\n\n int main ( ) { }" , actual.at (" " ));
614- ASSERT_EQUALS (" \n #line 1 \" abc.h\"\n class A { } ;\n #line 4 \" file.c\"\n int main ( ) { }" , actual.at (" ABC" ));
617+ ASSERT_EQUALS (" \n #line 1 \" abc.h\"\n class A { } ;\n #line 4 \" file.c\"\n int main ( ) { }" , actual.at (" ABC=ABC " ));
615618 }
616619
617620 void if0 () {
@@ -648,7 +651,7 @@ class TestPreprocessor : public TestFixture {
648651 " #else\n "
649652 " GHI\n "
650653 " #endif\n " ;
651- ASSERT_EQUALS (" \n DEF1\n DEF2\n " , getConfigsStr (filedata));
654+ ASSERT_EQUALS (" \n DEF1=DEF1 \n DEF2=DEF2 \n " , getConfigsStr (filedata));
652655 }
653656 }
654657
@@ -668,7 +671,7 @@ class TestPreprocessor : public TestFixture {
668671 " #if defined(A) && defined(B)\n "
669672 " ab\n "
670673 " #endif\n " ;
671- ASSERT_EQUALS (" \n A\n A; B\n " , getConfigsStr (filedata));
674+ ASSERT_EQUALS (" \n A=A \n A=A;B= B\n " , getConfigsStr (filedata));
672675
673676 if_cond2b ();
674677 if_cond2c ();
@@ -685,7 +688,7 @@ class TestPreprocessor : public TestFixture {
685688 " #else\n "
686689 " a\n "
687690 " #endif\n " ;
688- TODO_ASSERT_EQUALS (" \n A;B\n " , " \n A\n B\n " , getConfigsStr (filedata));
691+ TODO_ASSERT_EQUALS (" \n A;B=B \n " , " \n A\n B=B \n " , getConfigsStr (filedata));
689692 }
690693
691694 void if_cond2c () {
@@ -699,7 +702,7 @@ class TestPreprocessor : public TestFixture {
699702 " #else\n "
700703 " a\n "
701704 " #endif\n " ;
702- TODO_ASSERT_EQUALS (" \n A\n A;B\n " , " \n A\n B\n " , getConfigsStr (filedata));
705+ TODO_ASSERT_EQUALS (" \n A\n A;B=B \n " , " \n A\n B=B \n " , getConfigsStr (filedata));
703706 }
704707
705708 void if_cond2d () {
@@ -718,7 +721,7 @@ class TestPreprocessor : public TestFixture {
718721 " !b\n "
719722 " #endif\n "
720723 " #endif\n " ;
721- ASSERT_EQUALS (" \n A\n A;B\n B\n " , getConfigsStr (filedata));
724+ ASSERT_EQUALS (" \n A\n A;B=B \n B=B \n " , getConfigsStr (filedata));
722725 }
723726
724727 void if_cond2e () {
@@ -737,7 +740,7 @@ class TestPreprocessor : public TestFixture {
737740 " abc\n "
738741 " #endif\n "
739742 " #endif\n " ;
740- ASSERT_EQUALS (" \n A\n A;B; C\n " , getConfigsStr (filedata));
743+ ASSERT_EQUALS (" \n A=A \n A=A;B=B;C= C\n " , getConfigsStr (filedata));
741744 }
742745
743746 void if_cond4 () {
@@ -758,7 +761,7 @@ class TestPreprocessor : public TestFixture {
758761 " #endif\n "
759762 " }\n "
760763 " #endif\n " ;
761- ASSERT_EQUALS (" \n A\n A;B\n " , getConfigsStr (filedata));
764+ ASSERT_EQUALS (" \n A\n A;B=B \n " , getConfigsStr (filedata));
762765 }
763766
764767 {
@@ -793,20 +796,20 @@ class TestPreprocessor : public TestFixture {
793796 " #if defined(B) && defined(A)\n "
794797 " ef\n "
795798 " #endif\n " ;
796- ASSERT_EQUALS (" \n A; B\n " , getConfigsStr (filedata));
799+ ASSERT_EQUALS (" \n A=A;B= B\n " , getConfigsStr (filedata));
797800 }
798801
799802 void if_cond6 () {
800803 const char filedata[] = " \n "
801804 " #if defined(A) && defined(B))\n "
802805 " #endif\n " ;
803- ASSERT_EQUALS (" \n A; B\n " , getConfigsStr (filedata));
806+ ASSERT_EQUALS (" \n A=A;B= B\n " , getConfigsStr (filedata));
804807 }
805808
806809 void if_cond8 () {
807810 const char filedata[] = " #if defined(A) + defined(B) + defined(C) != 1\n "
808811 " #endif\n " ;
809- TODO_ASSERT_EQUALS (" \n A\n " , " \n A;B; C\n " , getConfigsStr (filedata));
812+ TODO_ASSERT_EQUALS (" \n A=A \n " , " \n A=A;B=B;C= C\n " , getConfigsStr (filedata));
810813 }
811814
812815
@@ -865,7 +868,7 @@ class TestPreprocessor : public TestFixture {
865868 const char filedata[] = " #if defined(DEF_10) || defined(DEF_11)\n "
866869 " a1;\n "
867870 " #endif\n " ;
868- ASSERT_EQUALS (" \n DEF_10; DEF_11\n " , getConfigsStr (filedata));
871+ ASSERT_EQUALS (" \n DEF_10=DEF_10;DEF_11= DEF_11\n " , getConfigsStr (filedata));
869872 }
870873
871874 void if_or_2 () {
@@ -1529,7 +1532,7 @@ class TestPreprocessor : public TestFixture {
15291532 ASSERT_EQUALS (2 , actual.size ());
15301533 const std::string expected (" void f ( ) {\n\n\n }" );
15311534 ASSERT_EQUALS (expected, actual.at (" " ));
1532- ASSERT_EQUALS (expected, actual.at (" A" ));
1535+ ASSERT_EQUALS (expected, actual.at (" A=A " ));
15331536 }
15341537
15351538 void handle_error () {
@@ -1649,7 +1652,7 @@ class TestPreprocessor : public TestFixture {
16491652 // Compare results..
16501653 ASSERT_EQUALS (2 , actual.size ());
16511654 ASSERT_EQUALS (" \n\n\n\n\n $20" , actual.at (" " ));
1652- ASSERT_EQUALS (" \n\n\n\n\n $10" , actual.at (" A" ));
1655+ ASSERT_EQUALS (" \n\n\n\n\n $10" , actual.at (" A=A " ));
16531656 ASSERT_EQUALS (" " , errout_str ());
16541657 }
16551658
@@ -1701,7 +1704,7 @@ class TestPreprocessor : public TestFixture {
17011704 // Compare results..
17021705 ASSERT_EQUALS (2 , actual.size ());
17031706 ASSERT_EQUALS (" " , actual.at (" " ));
1704- ASSERT_EQUALS (" \n A\n\n\n A" , actual.at (" ABC" ));
1707+ ASSERT_EQUALS (" \n A\n\n\n A" , actual.at (" ABC=ABC " ));
17051708 }
17061709
17071710 void define_if1 () {
@@ -1942,9 +1945,9 @@ class TestPreprocessor : public TestFixture {
19421945 // Compare results..
19431946 ASSERT_EQUALS (4 , actual.size ());
19441947 ASSERT (actual.find (" " ) != actual.end ());
1945- ASSERT (actual.find (" BAR" ) != actual.end ());
1946- ASSERT (actual.find (" FOO" ) != actual.end ());
1947- ASSERT (actual.find (" BAR; FOO" ) != actual.end ());
1948+ ASSERT (actual.find (" BAR=BAR " ) != actual.end ());
1949+ ASSERT (actual.find (" FOO=FOO " ) != actual.end ());
1950+ ASSERT (actual.find (" BAR=BAR;FOO= FOO" ) != actual.end ());
19481951 }
19491952
19501953
@@ -1978,9 +1981,9 @@ class TestPreprocessor : public TestFixture {
19781981 // cases should be fixed whenever this other bug is fixed
19791982 ASSERT_EQUALS (2U , actual.size ());
19801983
1981- ASSERT_EQUALS_MSG (true , (actual.find (" A" ) != actual.end ()), " A is expected to be checked but it was not checked" );
1984+ ASSERT_EQUALS_MSG (true , (actual.find (" A=A " ) != actual.end ()), " A is expected to be checked but it was not checked" );
19821985
1983- ASSERT_EQUALS_MSG (true , (actual.find (" A;A; B" ) == actual.end ()), " A;A;B is expected to NOT be checked but it was checked" );
1986+ ASSERT_EQUALS_MSG (true , (actual.find (" A=A;A=A;B= B" ) == actual.end ()), " A;A;B is expected to NOT be checked but it was checked" );
19841987 }
19851988
19861989 void invalid_define_1 () {
@@ -2146,7 +2149,7 @@ class TestPreprocessor : public TestFixture {
21462149 " qwerty\n "
21472150 " #endif \n " ;
21482151
2149- ASSERT_EQUALS (" \n WIN32\n " , getConfigsStr (filedata));
2152+ ASSERT_EQUALS (" \n WIN32=WIN32 \n " , getConfigsStr (filedata));
21502153 }
21512154
21522155 void getConfigs2 () {
@@ -2167,7 +2170,7 @@ class TestPreprocessor : public TestFixture {
21672170 " c\n "
21682171 " #endif\n " ;
21692172
2170- ASSERT_EQUALS (" \n ABC\n ABC; DEF\n " , getConfigsStr (filedata));
2173+ ASSERT_EQUALS (" \n ABC=ABC \n ABC=ABC;DEF= DEF\n " , getConfigsStr (filedata));
21712174 }
21722175
21732176 void getConfigs4 () {
@@ -2177,7 +2180,7 @@ class TestPreprocessor : public TestFixture {
21772180 " #ifdef ABC\n "
21782181 " A\n "
21792182 " #endif\n " ;
2180- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
2183+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
21812184 }
21822185
21832186 void getConfigs5 () {
@@ -2189,7 +2192,7 @@ class TestPreprocessor : public TestFixture {
21892192 " C\n "
21902193 " #endif\n "
21912194 " #endif\n " ;
2192- ASSERT_EQUALS (" \n ABC\n DEF\n " , getConfigsStr (filedata));
2195+ ASSERT_EQUALS (" \n ABC=ABC \n DEF=DEF \n " , getConfigsStr (filedata));
21932196 }
21942197
21952198 void getConfigs7 () {
@@ -2199,7 +2202,7 @@ class TestPreprocessor : public TestFixture {
21992202 " B\n "
22002203 " #endif\n "
22012204 " #endif\n " ;
2202- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
2205+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
22032206 }
22042207
22052208 void getConfigs7a () {
@@ -2219,7 +2222,7 @@ class TestPreprocessor : public TestFixture {
22192222 " B\n "
22202223 " #endif\n "
22212224 " #endif\n " ;
2222- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
2225+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
22232226 }
22242227
22252228 void getConfigs7c () {
@@ -2229,7 +2232,7 @@ class TestPreprocessor : public TestFixture {
22292232 " B\n "
22302233 " #endif\n "
22312234 " #endif\n " ;
2232- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
2235+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
22332236 }
22342237
22352238 void getConfigs7d () {
@@ -2239,7 +2242,7 @@ class TestPreprocessor : public TestFixture {
22392242 " B\n "
22402243 " #endif\n "
22412244 " #endif\n " ;
2242- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
2245+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
22432246 }
22442247
22452248 void getConfigs7e () {
@@ -2252,7 +2255,7 @@ class TestPreprocessor : public TestFixture {
22522255 " #endif\n "
22532256 " #endfile\n "
22542257 " #endif\n " ;
2255- ASSERT_EQUALS (" \n ABC\n " , getConfigsStr (filedata));
2258+ ASSERT_EQUALS (" \n ABC=ABC \n " , getConfigsStr (filedata));
22562259 }
22572260
22582261 void getConfigs8 () {
@@ -2334,7 +2337,7 @@ class TestPreprocessor : public TestFixture {
23342337 " #error \" !Y\"\n "
23352338 " #endif\n "
23362339 " #endif\n " ;
2337- ASSERT_EQUALS (" \n X;Y\n Y\n " , getConfigsStr (filedata2));
2340+ ASSERT_EQUALS (" \n X=X ;Y\n Y\n " , getConfigsStr (filedata2));
23382341 }
23392342
23402343 void getConfigsD1 () {
@@ -2344,14 +2347,14 @@ class TestPreprocessor : public TestFixture {
23442347 " #endif\n "
23452348 " #endif\n " ;
23462349 ASSERT_EQUALS (" \n " , getConfigsStr (filedata, " -DX" ));
2347- ASSERT_EQUALS (" \n X\n Y\n " , getConfigsStr (filedata));
2350+ ASSERT_EQUALS (" \n X=X \n Y=Y \n " , getConfigsStr (filedata));
23482351 }
23492352
23502353 void getConfigsU1 () {
23512354 const char filedata[] = " #ifdef X\n "
23522355 " #endif\n " ;
23532356 ASSERT_EQUALS (" \n " , getConfigsStr (filedata, " -UX" ));
2354- ASSERT_EQUALS (" \n X\n " , getConfigsStr (filedata));
2357+ ASSERT_EQUALS (" \n X=X \n " , getConfigsStr (filedata));
23552358 }
23562359
23572360 void getConfigsU2 () {
@@ -2375,8 +2378,8 @@ class TestPreprocessor : public TestFixture {
23752378 const char filedata[] = " #if defined(X) || defined(Y) || defined(Z)\n "
23762379 " #else\n "
23772380 " #endif\n " ;
2378- ASSERT_EQUALS (" \n Y; Z\n " , getConfigsStr (filedata, " -UX" ));
2379- ASSERT_EQUALS (" \n X;Y; Z\n " , getConfigsStr (filedata));
2381+ ASSERT_EQUALS (" \n Y=Y;Z= Z\n " , getConfigsStr (filedata, " -UX" ));
2382+ ASSERT_EQUALS (" \n X=X;Y=Y;Z= Z\n " , getConfigsStr (filedata));
23802383 }
23812384
23822385 void getConfigsU5 () {
@@ -2400,6 +2403,40 @@ class TestPreprocessor : public TestFixture {
24002403 ASSERT_EQUALS (" \n Y\n " , getConfigsStr (code, " -DX" ));
24012404 }
24022405
2406+ void getConfigsIssue14317 () {
2407+ const char filedata[] = " bool test() {\n "
2408+ " return\n "
2409+ " #if defined(isless)\n "
2410+ " 0 != isless(1.0, 2.0)\n "
2411+ " #else\n "
2412+ " 0\n "
2413+ " #endif\n "
2414+ " ;\n "
2415+ " }\n " ;
2416+ ASSERT_EQUALS (" \n isless=isless\n " , getConfigsStr (filedata));
2417+ }
2418+
2419+ void getCodeIssue14317 () {
2420+ // Handling include guards..
2421+ const char filedata[] = " bool test() {\n "
2422+ " return\n "
2423+ " #if defined(isless)\n "
2424+ " 0 != isless(1.0, 2.0)\n "
2425+ " #else\n "
2426+ " 0\n "
2427+ " #endif\n "
2428+ " ;\n "
2429+ " }\n " ;
2430+
2431+ // Preprocess => actual result..
2432+ const std::map<std::string, std::string> actual = getcode (settings0, *this , filedata);
2433+
2434+ // Expected configurations: "" and "ABC"
2435+ ASSERT_EQUALS (2 , actual.size ());
2436+ ASSERT_EQUALS (" bool test ( ) {\n return\n\n\n\n 0\n\n ;\n }" , actual.at (" " ));
2437+ ASSERT_EQUALS (" bool test ( ) {\n return\n\n 0 != $isless ( 1.0 , 2.0 )\n\n\n\n ;\n }" , actual.at (" isless=isless" ));
2438+ }
2439+
24032440 void if_sizeof () { // #4071
24042441 const char code[] = " #if sizeof(unsigned short) == 2\n "
24052442 " Fred & Wilma\n "
0 commit comments