From 937f9fb86dc6dd4bf0d4a7765312b049fd2d7da5 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Wed, 11 Mar 2015 18:30:21 -0700 Subject: [PATCH] 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. --- compat/testPreCompiler.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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); } -- 2.47.2