~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/icmp/testIcmp.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define SQUID_UNIT_TEST 1
 
2
#define SQUID_HELPER 1
 
3
 
 
4
#include "squid.h"
 
5
 
 
6
#include <cppunit/TestAssert.h>
 
7
 
 
8
#include "testIcmp.h"
 
9
 
 
10
CPPUNIT_TEST_SUITE_REGISTRATION( testIcmp );
 
11
 
 
12
#if USE_ICMP
 
13
 
 
14
void
 
15
testIcmp::testChecksum()
 
16
{
 
17
    stubIcmp icmp;
 
18
    short unsigned int buf[10] = {1,2,3,4,5,6,7,8,9};
 
19
 
 
20
    // NULL data
 
21
    CPPUNIT_ASSERT_EQUAL(65535, icmp.testChecksum(NULL,0));
 
22
 
 
23
    // NULL data with length!!
 
24
    CPPUNIT_ASSERT_EQUAL(65535, icmp.testChecksum(NULL,1));
 
25
 
 
26
    // data with 0 length
 
27
    CPPUNIT_ASSERT_EQUAL(65535, icmp.testChecksum(buf,0));
 
28
 
 
29
    // data with invalid length (low)
 
30
    CPPUNIT_ASSERT_EQUAL(65534, icmp.testChecksum(buf,1));
 
31
 
 
32
    // data with invalid length (max-low)
 
33
    CPPUNIT_ASSERT_EQUAL(65520, icmp.testChecksum(buf,9));
 
34
 
 
35
    // data with accurate length
 
36
    CPPUNIT_ASSERT_EQUAL(65520, icmp.testChecksum(buf,10));
 
37
 
 
38
    // data with invalid length (overrun)
 
39
    CPPUNIT_ASSERT_EQUAL(65514, icmp.testChecksum(buf,11));
 
40
}
 
41
 
 
42
void
 
43
testIcmp::testHops()
 
44
{
 
45
    stubIcmp icmp;
 
46
 
 
47
    /* test invalid -(under values) */
 
48
    // negative     : n > 33
 
49
    CPPUNIT_ASSERT_EQUAL(34, icmp.testHops(-1));
 
50
    // zero
 
51
    CPPUNIT_ASSERT_EQUAL(33, icmp.testHops(0));
 
52
 
 
53
    /* test each valid case boundary */
 
54
    // n(1...32)    : 32 >= n >= 1
 
55
    CPPUNIT_ASSERT_EQUAL(32, icmp.testHops(1));
 
56
    CPPUNIT_ASSERT_EQUAL(1, icmp.testHops(32));
 
57
 
 
58
    // n(33...62)   : 30 >= n >= 1
 
59
    CPPUNIT_ASSERT_EQUAL(30, icmp.testHops(33));
 
60
    CPPUNIT_ASSERT_EQUAL(1, icmp.testHops(62));
 
61
 
 
62
    // n(63...64)  : 2 >= n >= 1
 
63
    CPPUNIT_ASSERT_EQUAL(2, icmp.testHops(63));
 
64
    CPPUNIT_ASSERT_EQUAL(1, icmp.testHops(64));
 
65
 
 
66
    // n(65...128)  : 64 >= n >= 1
 
67
    CPPUNIT_ASSERT_EQUAL(64, icmp.testHops(65));
 
68
    CPPUNIT_ASSERT_EQUAL(1, icmp.testHops(128));
 
69
 
 
70
    // n(129...192) : 64 >= n >= 1
 
71
    CPPUNIT_ASSERT_EQUAL(64, icmp.testHops(129));
 
72
    CPPUNIT_ASSERT_EQUAL(1, icmp.testHops(192));
 
73
 
 
74
    // n(193...)    : n < 63
 
75
    CPPUNIT_ASSERT_EQUAL(63, icmp.testHops(193));
 
76
    CPPUNIT_ASSERT_EQUAL(1, icmp.testHops(255));
 
77
 
 
78
    /* test invalid (over values) */
 
79
    // 256 - produces zero
 
80
    CPPUNIT_ASSERT_EQUAL(0, icmp.testHops(256));
 
81
    // 257 - produces negative hops
 
82
    CPPUNIT_ASSERT_EQUAL(-1, icmp.testHops(257));
 
83
}
 
84
 
 
85
#endif /* USE_ICMP */