]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/testPreCompiler.cc
1 #define SQUID_UNIT_TEST 1
6 #include "testPreCompiler.h"
8 CPPUNIT_TEST_SUITE_REGISTRATION( testPreCompiler
);
11 * Test several ways of defining pre-compiler directives.
12 * Squid-3 uses #if FOO syntax for precompiler directives.
13 * These tests ensure that the inputs will work as expected.
16 testPreCompiler::testIfDef()
18 /* Defined to explicit value 1 should be true */
28 bool oneFalse
= false;
30 CPPUNIT_ASSERT(oneTrue
);
31 CPPUNIT_ASSERT(!oneFalse
);
33 /* Defined to explicit value 0 should be false */
38 bool zeroTrue
= false;
41 bool zeroFalse
= true;
43 bool zeroFalse
= false;
45 CPPUNIT_ASSERT(zeroFalse
);
46 CPPUNIT_ASSERT(!zeroTrue
);
48 /* Defined to exist without a value generates pre-compiler errors when used in #if . */
50 /* Not Defined to exist at all == false */
53 bool undefinedTrue
= true;
55 bool undefinedTrue
= false;
58 bool undefinedFalse
= true;
60 bool undefinedFalse
= false;
62 CPPUNIT_ASSERT(undefinedFalse
);
63 CPPUNIT_ASSERT(!undefinedTrue
);
67 * Test several ways of defining pre-compiler directives.
68 * Squid-3 uses #if FOO syntax for precompiler directives.
69 * These tests ensure that the inputs will work as expected
70 * when undefined macros are used in && conditions
73 testPreCompiler::testIfDefAnd()
75 /* Not Defined to exist at all == false - when used in a compound if */
79 #if UNDEFINED_FOO && ONE_FOO
80 bool undefinedAndTrueA
= true;
82 bool undefinedAndTrueA
= false;
84 #if !UNDEFINED_FOO && ONE_FOO
85 bool undefinedAndFalseA
= true;
87 bool undefinedAndFalseA
= false;
89 CPPUNIT_ASSERT(undefinedAndFalseA
);
90 CPPUNIT_ASSERT(!undefinedAndTrueA
);
92 #if ONE_FOO && UNDEFINED_FOO
93 bool undefinedAndTrueB
= true;
95 bool undefinedAndTrueB
= false;
97 #if ONE_FOO && !UNDEFINED_FOO
98 bool undefinedAndFalseB
= true;
100 bool undefinedAndFalseB
= false;
102 CPPUNIT_ASSERT(undefinedAndFalseB
);
103 CPPUNIT_ASSERT(!undefinedAndTrueB
);
107 * Test several ways of defining pre-compiler directives.
108 * Squid-3 uses #if FOO syntax for precompiler directives.
109 * These tests ensure that the inputs will work as expected
110 * when undefined macros are used in || conditions
113 testPreCompiler::testIfDefOr()
115 /* Not Defined to exist at all == false - when used in a compound if */
119 #if UNDEFINED_FOO || ZERO_FOO
120 bool undefinedOrTrueA
= true;
122 bool undefinedOrTrueA
= false;
124 #if !UNDEFINED_FOO || ZERO_FOO
125 bool undefinedOrFalseA
= true;
127 bool undefinedOrFalseA
= false;
129 CPPUNIT_ASSERT(undefinedOrFalseA
);
130 CPPUNIT_ASSERT(!undefinedOrTrueA
);
132 #if ZERO_FOO || UNDEFINED_FOO
133 bool undefinedOrTrueB
= true;
135 bool undefinedOrTrueB
= false;
137 #if ZERO_FOO || !UNDEFINED_FOO
138 bool undefinedOrFalseB
= true;
140 bool undefinedOrFalseB
= false;
142 CPPUNIT_ASSERT(undefinedOrFalseB
);
143 CPPUNIT_ASSERT(!undefinedOrTrueB
);