-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinterfaces_test.go
More file actions
58 lines (51 loc) · 1.38 KB
/
interfaces_test.go
File metadata and controls
58 lines (51 loc) · 1.38 KB
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
// -----------------------------------------------------------------------------
// github.com/balacode/udpt /[interfaces_test.go]
// (c) balarabe@protonmail.com License: MIT
// -----------------------------------------------------------------------------
package udpt
import (
"net"
"testing"
)
// netDialUDP(network string, laddr, raddr *net.UDPAddr) (netUDPConn, error)
//
// go test -run Test_netDialUDP_*
// must succeed
func Test_netDialUDP_1(t *testing.T) {
conn, err := netDialUDP("udp", nil,
&net.UDPAddr{IP: []byte{127, 0, 0, 0}, Port: 9876})
if conn == nil {
t.Error("0xE3E28A")
}
if v, ok := conn.(*net.UDPConn); ok {
if v == nil {
t.Error("0xE9F3B4")
}
} else {
t.Error("0xEE14A6")
}
if err != nil {
t.Error("0xEF38D1")
}
}
// must fail and return nil and an error because network is invalid
func Test_netDialUDP_2(t *testing.T) {
conn, err := netDialUDP("badnet", nil, nil)
if conn != nil {
t.Error("0xE0E64E")
}
if !matchError(err, "unknown network") {
t.Error("0xE75C27", "wrong error:", err)
}
}
// must fail and return nil and an error because addres is not specified
func Test_netDialUDP_3(t *testing.T) {
conn, err := netDialUDP("udp", nil, nil)
if conn != nil {
t.Error("0xE37D46")
}
if !matchError(err, "missing address") {
t.Error("0xEB08F4", "wrong error:", err)
}
}
// end