]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testString.cc
Bug 2358: FD_SIZELIMIT redefined FBSD 7.0
[thirdparty/squid.git] / src / tests / testString.cc
1 #include "config.h"
2
3 #include "testString.h"
4 #include "SquidString.h"
5 #include "Mem.h"
6 #include "event.h"
7
8 CPPUNIT_TEST_SUITE_REGISTRATION( testString );
9
10 /* let this test link sanely */
11 void
12 eventAdd(const char *name, EVH * func, void *arg, double when, int, bool cbdata)
13 {}
14
15 /* init memory pools */
16
17 void
18 testString::setUp()
19 {
20 Mem::Init();
21 }
22
23 void
24 testString::testCmpDefault()
25 {
26 String left, right;
27 /* two default strings are equal */
28 CPPUNIT_ASSERT(!left.cmp(right));
29 CPPUNIT_ASSERT(!left.cmp(NULL));
30 CPPUNIT_ASSERT(!left.cmp(NULL, 1));
31 }
32
33 void
34 testString::testCmpEmptyString()
35 {
36 String left("");
37 String right;
38 /* an empty string ("") is equal to a default string */
39 CPPUNIT_ASSERT(!left.cmp(right));
40 CPPUNIT_ASSERT(!left.cmp(NULL));
41 CPPUNIT_ASSERT(!left.cmp(NULL, 1));
42 /* reverse the order to catch corners */
43 CPPUNIT_ASSERT(!right.cmp(left));
44 CPPUNIT_ASSERT(!right.cmp(""));
45 CPPUNIT_ASSERT(!right.cmp("", 1));
46 }
47
48 void
49 testString::testCmpNotEmptyDefault()
50 {
51 String left("foo");
52 String right;
53 /* empty string sorts before everything */
54 CPPUNIT_ASSERT(left.cmp(right) > 0);
55 CPPUNIT_ASSERT(left.cmp(NULL) > 0);
56 CPPUNIT_ASSERT(left.cmp(NULL, 1) > 0);
57 /* reverse for symmetry tests */
58 CPPUNIT_ASSERT(right.cmp(left) < 0);
59 CPPUNIT_ASSERT(right.cmp("foo") < 0);
60 CPPUNIT_ASSERT(right.cmp("foo", 1) < 0);
61 }