From: Amos Jeffries Date: Thu, 12 Mar 2015 01:30:21 +0000 (-0700) Subject: Tests: extend pre-compiler unit tests to check macro permutations X-Git-Tag: merge-candidate-3-v1~223 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=937f9fb86dc6dd4bf0d4a7765312b049fd2d7da5;p=thirdparty%2Fsquid.git Tests: extend pre-compiler unit tests to check macro permutations 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. --- diff --git a/compat/testPreCompiler.cc b/compat/testPreCompiler.cc index eac4bb749e..e713ccedc4 100644 --- a/compat/testPreCompiler.cc +++ b/compat/testPreCompiler.cc @@ -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); }