]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testString.cc
3 #include "testString.h"
4 #include "SquidString.h"
8 CPPUNIT_TEST_SUITE_REGISTRATION( testString
);
10 /* let this test link sanely */
12 eventAdd(const char *name
, EVH
* func
, void *arg
, double when
, int, bool cbdata
)
15 /* init memory pools */
24 testString::testCmpDefault()
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));
34 testString::testCmpEmptyString()
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));
49 testString::testCmpNotEmptyDefault()
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);