]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/testNetDb.cc
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "icmp/net_db.h"
11 #include "tests/testNetDb.h"
12 #include "unitTestMain.h"
16 CPPUNIT_TEST_SUITE_REGISTRATION( testNetDb
);
19 testNetDb::testConstruct()
21 // default construct and destruct
24 CPPUNIT_ASSERT_EQUAL(T
.network
[0], '\0');
25 CPPUNIT_ASSERT_EQUAL(0, T
.pings_sent
);
26 CPPUNIT_ASSERT_EQUAL(0, T
.pings_recv
);
27 CPPUNIT_ASSERT_EQUAL(0.0, T
.hops
);
28 CPPUNIT_ASSERT_EQUAL(1.0, T
.rtt
);
29 CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(0), T
.next_ping_time
);
30 CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(0), T
.last_use_time
);
31 CPPUNIT_ASSERT_EQUAL(0, T
.link_count
);
32 CPPUNIT_ASSERT_EQUAL(static_cast<net_db_name
*>(nullptr), T
.hosts
);
33 CPPUNIT_ASSERT_EQUAL(static_cast<net_db_peer
*>(nullptr), T
.peers
);
34 CPPUNIT_ASSERT_EQUAL(0, T
.n_peers_alloc
);
35 CPPUNIT_ASSERT_EQUAL(0, T
.n_peers
);
38 // new and delete operations
40 netdbEntry
*T
= new netdbEntry
;
41 CPPUNIT_ASSERT_EQUAL(T
->network
[0], '\0');
42 CPPUNIT_ASSERT_EQUAL(0, T
->pings_sent
);
43 CPPUNIT_ASSERT_EQUAL(0, T
->pings_recv
);
44 CPPUNIT_ASSERT_EQUAL(0.0, T
->hops
);
45 CPPUNIT_ASSERT_EQUAL(1.0, T
->rtt
);
46 CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(0), T
->next_ping_time
);
47 CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(0), T
->last_use_time
);
48 CPPUNIT_ASSERT_EQUAL(0, T
->link_count
);
49 CPPUNIT_ASSERT_EQUAL(static_cast<net_db_name
*>(nullptr), T
->hosts
);
50 CPPUNIT_ASSERT_EQUAL(static_cast<net_db_peer
*>(nullptr), T
->peers
);
51 CPPUNIT_ASSERT_EQUAL(0, T
->n_peers_alloc
);
52 CPPUNIT_ASSERT_EQUAL(0, T
->n_peers
);