]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Tests: extend pre-compiler unit tests to check macro permutations
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 12 Mar 2015 01:30:21 +0000 (18:30 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 12 Mar 2015 01:30:21 +0000 (18:30 -0700)
We are getting come complaints about precompiler issues building with
#if FOO && FOO || FOO boolean constructs using undefined macros.

The particualr form reported so far dies when building the test, so will
be found earlier than these checks are run. This is to ensure its not a
widespread subtle error in other "working" installations.

compat/testPreCompiler.cc

index eac4bb749e97ba06b2b732ec38d26fd13625660b..e713ccedc4e8718ef0e0262011b174a094f05d5b 100644 (file)
@@ -108,6 +108,19 @@ testPreCompiler::testIfDefAnd()
 #endif
     CPPUNIT_ASSERT(undefinedAndFalseB);
     CPPUNIT_ASSERT(!undefinedAndTrueB);
+
+#if UNDEFINED_FOO && UNDEFINED_FOO
+    bool undefinedAndUndefinedC = true;
+#else
+    bool undefinedAndUndefinedC = false;
+#endif
+#if !UNDEFINED_FOO && !UNDEFINED_FOO
+    bool notUndefinedAndNotUndefinedC = true;
+#else
+    bool notUndefinedAndNotUndefinedC = false;
+#endif
+    CPPUNIT_ASSERT(!undefinedAndUndefinedC);
+    CPPUNIT_ASSERT(notUndefinedAndNotUndefinedC);
 }
 
 /**
@@ -149,5 +162,17 @@ testPreCompiler::testIfDefOr()
     CPPUNIT_ASSERT(undefinedOrFalseB);
     CPPUNIT_ASSERT(!undefinedOrTrueB);
 
+#if UNDEFINED_FOO || UNDEFINED_FOO
+    bool undefinedOrUndefinedC = true;
+#else
+    bool undefinedOrUndefinedC = false;
+#endif
+#if !UNDEFINED_FOO || !UNDEFINED_FOO
+    bool notUndefinedOrNotUndefinedC = true;
+#else
+    bool notUndefinedOrNotUndefinedC = false;
+#endif
+    CPPUNIT_ASSERT(notUndefinedOrNotUndefinedC);
+    CPPUNIT_ASSERT(!undefinedOrUndefinedC);
 }