-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
exclude_test.go
52 lines (44 loc) · 902 Bytes
/
exclude_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
// Test of ConnectIpPort.exclude function
package teonet
import (
"errors"
"fmt"
"testing"
)
func TestExcludeIPs(t *testing.T) {
var ErrWrong = errors.New("wrong execution")
var con ConnectIpPort
nodeAddr := []NodeAddr{
{"129.0.0.1", 121},
{"127.0.0.1", 122},
{"128.0.0.1", 123},
{"129.0.0.1", 124},
{"128.0.0.1", 125},
{"127.0.0.1", 126},
}
fmt.Println(nodeAddr)
nodeAddr = con.exclude(nodeAddr, "128.0.0.1")
fmt.Println(nodeAddr)
if len(nodeAddr) != 4 {
t.Error(ErrWrong)
return
}
nodeAddr = con.exclude(nodeAddr, "127.0.0.1")
fmt.Println(nodeAddr)
if len(nodeAddr) != 2 {
t.Error(ErrWrong)
return
}
nodeAddr = con.exclude(nodeAddr, "130.0.0.1")
fmt.Println(nodeAddr)
if len(nodeAddr) != 2 {
t.Error(ErrWrong)
return
}
nodeAddr = con.exclude(nodeAddr, "129.0.0.1")
fmt.Println(nodeAddr)
if len(nodeAddr) != 0 {
t.Error(ErrWrong)
return
}
}