forked from berthubert/googerteller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testrunner.cc
45 lines (31 loc) · 856 Bytes
/
testrunner.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "ext/doctest.h"
#include "lpmwrapper.hh"
using namespace std;
TEST_CASE("basic test") {
LPMWrapper t;
void* ptr = (void*)1;
t.insert("127.0.0.1/32", ptr);
CHECK(t.lookup("127.0.0.1") == ptr);
CHECK(t.lookup("127.0.0.2") == 0);
}
TEST_CASE("IPv6 test") {
LPMWrapper t;
void* ptr = (void*)1;
t.insert("::1", ptr);
CHECK(t.lookup("::1") == ptr);
CHECK(t.lookup("::2") == 0);
}
TEST_CASE("Mixed test") {
LPMWrapper t;
void* ptr = (void*)1;
t.insert("::1", ptr);
ptr = (void*)2;
t.insert("192.168.0.0/16", ptr);
CHECK(t.lookup("::1") == (void*)1);
CHECK(t.lookup("192.168.1.1") == (void*)2);
CHECK(t.lookup("192.168.255.255") == (void*)2);
CHECK(t.lookup("10.0.0.1") == 0);
CHECK(t.lookup("172.16.2.3") == 0);
CHECK(t.lookup("1.0.0.0") == 0);
}