forked from signalsciences/ipv4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_test.go
81 lines (72 loc) · 1.6 KB
/
set_test.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package ipv4
import "testing"
func TestAdd(t *testing.T) {
s := Set{}
if s.Len() != 0 {
t.Errorf("Size is not 0: %d", s.Len())
}
if s.Valid() == false {
t.Errorf("invalid 0")
}
if s.Contains("12.12.12.12") == true {
t.Errorf("Contains on empty set returned true")
}
if s.Add("12.12.12.12") == false {
t.Errorf("Unable to insert")
}
if s.Len() != 1 {
t.Errorf("Size is not 1: %d", s.Len())
}
if s.Valid() == false {
t.Errorf("invalid 1")
}
if s.Add("12.12.12.12") == true {
t.Errorf("Inserted duplicate")
}
if s.Contains("12.12.12.12") == false {
t.Errorf("Unable to find 12.12.12.12")
}
if s.Add("1.1.1.1") == false {
t.Errorf("Unable to insert 1")
}
if s.Len() != 2 {
t.Errorf("Size is not 2: %d", s.Len())
}
if s.Valid() == false {
t.Errorf("invalid 2")
}
if s.Contains("12.12.12.12") == false {
t.Errorf("Unable to find 12.12.12.12")
}
if s.Contains("1.1.1.1") == false {
t.Errorf("Unable to find 1.1.1.1")
}
if s.Add("6.6.6.6") == false {
t.Errorf("Unable to insert 1")
}
if s.Len() != 3 {
t.Errorf("Size is not 3: %d", s.Len())
}
if s.Valid() == false {
t.Errorf("invalid 3")
}
if s.Contains("12.12.12.12") == false {
t.Errorf("Unable to find 12.12.12.12")
}
if s.Contains("1.1.1.1") == false {
t.Errorf("Unable to find 1.1.1.1")
}
if s.Contains("6.6.6.6") == false {
t.Errorf("Unable to find 6.6.6.6")
}
if s.Add("junk") == true {
t.Errorf("Accepted junk input")
}
if s.Contains("junk") == true {
t.Errorf("Accepted junk input")
}
s.Raw = append(s.Raw, uint32(0))
if s.Valid() {
t.Errorf("have s.Valid() == true, want false")
}
}