]>
Commit | Line | Data |
---|---|---|
1a7cfe02 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
1a7cfe02 AJ |
3 | * |
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. | |
7 | */ | |
8 | ||
9 | #include "squid.h" | |
10 | #include "icmp/net_db.h" | |
11 | #include "tests/testNetDb.h" | |
12 | #include "unitTestMain.h" | |
13 | ||
14 | #include <stdexcept> | |
15 | ||
16 | CPPUNIT_TEST_SUITE_REGISTRATION( testNetDb ); | |
17 | ||
18 | void | |
19 | testNetDb::testConstruct() | |
20 | { | |
21 | // default construct and destruct | |
22 | { | |
23 | netdbEntry T; | |
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); | |
36 | } | |
37 | ||
38 | // new and delete operations | |
39 | { | |
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); | |
53 | delete T; | |
54 | } | |
55 | } | |
56 |