~ubuntu-branches/ubuntu/oneiric/squid3/oneiric-security

« back to all changes in this revision

Viewing changes to compat/testPreCompiler.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mahyuddin Susanto
  • Date: 2011-02-15 18:46:13 UTC
  • mfrom: (21.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110215184613-1u3dh5sz4i055flk
Tags: 3.1.10-1ubuntu1
* Merge from debian unstable. (LP: #719283)  Remaining changes:
  - debian/patches/18-fix-ftbfs-binutils-gold.dpatch: Add library linker into
    LIBS instead to LDFLAGS to fixing FTBFS binutils-gold.
* Drop Ubuntu configuration for ufw which landed in Debian and sync it: 
  - debian/squid3.ufw.profile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    CPPUNIT_ASSERT(undefinedFalse);
64
64
    CPPUNIT_ASSERT(!undefinedTrue);
65
65
}
 
66
 
 
67
/**
 
68
 * Test several ways of defining pre-compiler directives.
 
69
 * Squid-3 uses #if FOO syntax for precompiler directives.
 
70
 * These tests ensure that the inputs will work as expected
 
71
 * when undefined macros are used in && conditions
 
72
 */
 
73
void
 
74
testPreCompiler::testIfDefAnd()
 
75
{
 
76
    /* Not Defined to exist at all == false - when used in a compound if */
 
77
#undef UNDEFINED_FOO
 
78
#define ONE_FOO 1
 
79
 
 
80
#if UNDEFINED_FOO && ONE_FOO
 
81
    bool undefinedAndTrueA = true;
 
82
#else
 
83
    bool undefinedAndTrueA = false;
 
84
#endif
 
85
#if !UNDEFINED_FOO && ONE_FOO
 
86
    bool undefinedAndFalseA = true;
 
87
#else
 
88
    bool undefinedAndFalseA = false;
 
89
#endif
 
90
    CPPUNIT_ASSERT(undefinedAndFalseA);
 
91
    CPPUNIT_ASSERT(!undefinedAndTrueA);
 
92
 
 
93
#if ONE_FOO && UNDEFINED_FOO
 
94
    bool undefinedAndTrueB = true;
 
95
#else
 
96
    bool undefinedAndTrueB = false;
 
97
#endif
 
98
#if ONE_FOO && !UNDEFINED_FOO
 
99
    bool undefinedAndFalseB = true;
 
100
#else
 
101
    bool undefinedAndFalseB = false;
 
102
#endif
 
103
    CPPUNIT_ASSERT(undefinedAndFalseB);
 
104
    CPPUNIT_ASSERT(!undefinedAndTrueB);
 
105
}
 
106
 
 
107
/**
 
108
 * Test several ways of defining pre-compiler directives.
 
109
 * Squid-3 uses #if FOO syntax for precompiler directives.
 
110
 * These tests ensure that the inputs will work as expected
 
111
 * when undefined macros are used in || conditions
 
112
 */
 
113
void
 
114
testPreCompiler::testIfDefOr()
 
115
{
 
116
    /* Not Defined to exist at all == false - when used in a compound if */
 
117
#undef UNDEFINED_FOO
 
118
#define ZERO_FOO 0
 
119
 
 
120
#if UNDEFINED_FOO || ZERO_FOO
 
121
    bool undefinedOrTrueA = true;
 
122
#else
 
123
    bool undefinedOrTrueA = false;
 
124
#endif
 
125
#if !UNDEFINED_FOO || ZERO_FOO
 
126
    bool undefinedOrFalseA = true;
 
127
#else
 
128
    bool undefinedOrFalseA = false;
 
129
#endif
 
130
    CPPUNIT_ASSERT(undefinedOrFalseA);
 
131
    CPPUNIT_ASSERT(!undefinedOrTrueA);
 
132
 
 
133
#if ZERO_FOO || UNDEFINED_FOO
 
134
    bool undefinedOrTrueB = true;
 
135
#else
 
136
    bool undefinedOrTrueB = false;
 
137
#endif
 
138
#if ZERO_FOO || !UNDEFINED_FOO
 
139
    bool undefinedOrFalseB = true;
 
140
#else
 
141
    bool undefinedOrFalseB = false;
 
142
#endif
 
143
    CPPUNIT_ASSERT(undefinedOrFalseB);
 
144
    CPPUNIT_ASSERT(!undefinedOrTrueB);
 
145
 
 
146
}
 
147