testNetDb.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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 
17 
18 void
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 
void testConstruct()
Definition: testNetDb.cc:19
int n_peers
Definition: net_db.h:64
double rtt
Definition: net_db.h:57
time_t next_ping_time
Definition: net_db.h:58
double hops
Definition: net_db.h:56
CPPUNIT_TEST_SUITE_REGISTRATION(testNetDb)
int pings_sent
Definition: net_db.h:54
int link_count
Definition: net_db.h:60
char network[MAX_IPSTRLEN]
Definition: net_db.h:53
int n_peers_alloc
Definition: net_db.h:63
net_db_name * hosts
Definition: net_db.h:61
net_db_peer * peers
Definition: net_db.h:62
int pings_recv
Definition: net_db.h:55
time_t last_use_time
Definition: net_db.h:59

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors