]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/testPreCompiler.cc
1 #define SQUID_UNIT_TEST 1
8 #include "testPreCompiler.h"
10 CPPUNIT_TEST_SUITE_REGISTRATION( testPreCompiler
);
13 * Test several ways of defining pre-compiler directives.
14 * Squid-3 uses #if FOO syntax for precompiler directives.
15 * These tests ensure that the inputs will work as expected.
18 testPreCompiler::testIfDef()
20 /* Defined to explicit value 1 should be true */
30 bool oneFalse
= false;
32 CPPUNIT_ASSERT(oneTrue
);
33 CPPUNIT_ASSERT(!oneFalse
);
35 /* Defined to explicit value 0 should be false */
40 bool zeroTrue
= false;
43 bool zeroFalse
= true;
45 bool zeroFalse
= false;
47 CPPUNIT_ASSERT(zeroFalse
);
48 CPPUNIT_ASSERT(!zeroTrue
);
50 /* Defined to exist without a value generates pre-compiler errors when used in #if . */
52 /* Not Defined to exist at all == false */
55 bool undefinedTrue
= true;
57 bool undefinedTrue
= false;
60 bool undefinedFalse
= true;
62 bool undefinedFalse
= false;
64 CPPUNIT_ASSERT(undefinedFalse
);
65 CPPUNIT_ASSERT(!undefinedTrue
);
69 * Test several ways of defining pre-compiler directives.
70 * Squid-3 uses #if FOO syntax for precompiler directives.
71 * These tests ensure that the inputs will work as expected
72 * when undefined macros are used in && conditions
75 testPreCompiler::testIfDefAnd()
77 /* Not Defined to exist at all == false - when used in a compound if */
81 #if UNDEFINED_FOO && ONE_FOO
82 bool undefinedAndTrueA
= true;
84 bool undefinedAndTrueA
= false;
86 #if !UNDEFINED_FOO && ONE_FOO
87 bool undefinedAndFalseA
= true;
89 bool undefinedAndFalseA
= false;
91 CPPUNIT_ASSERT(undefinedAndFalseA
);
92 CPPUNIT_ASSERT(!undefinedAndTrueA
);
94 #if ONE_FOO && UNDEFINED_FOO
95 bool undefinedAndTrueB
= true;
97 bool undefinedAndTrueB
= false;
99 #if ONE_FOO && !UNDEFINED_FOO
100 bool undefinedAndFalseB
= true;
102 bool undefinedAndFalseB
= false;
104 CPPUNIT_ASSERT(undefinedAndFalseB
);
105 CPPUNIT_ASSERT(!undefinedAndTrueB
);
109 * Test several ways of defining pre-compiler directives.
110 * Squid-3 uses #if FOO syntax for precompiler directives.
111 * These tests ensure that the inputs will work as expected
112 * when undefined macros are used in || conditions
115 testPreCompiler::testIfDefOr()
117 /* Not Defined to exist at all == false - when used in a compound if */
121 #if UNDEFINED_FOO || ZERO_FOO
122 bool undefinedOrTrueA
= true;
124 bool undefinedOrTrueA
= false;
126 #if !UNDEFINED_FOO || ZERO_FOO
127 bool undefinedOrFalseA
= true;
129 bool undefinedOrFalseA
= false;
131 CPPUNIT_ASSERT(undefinedOrFalseA
);
132 CPPUNIT_ASSERT(!undefinedOrTrueA
);
134 #if ZERO_FOO || UNDEFINED_FOO
135 bool undefinedOrTrueB
= true;
137 bool undefinedOrTrueB
= false;
139 #if ZERO_FOO || !UNDEFINED_FOO
140 bool undefinedOrFalseB
= true;
142 bool undefinedOrFalseB
= false;
144 CPPUNIT_ASSERT(undefinedOrFalseB
);
145 CPPUNIT_ASSERT(!undefinedOrTrueB
);