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