-
Notifications
You must be signed in to change notification settings - Fork 16
/
net_test.go
40 lines (34 loc) · 864 Bytes
/
net_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
package pgo_test
import (
"github.com/arthurkushman/pgo"
"github.com/stretchr/testify/assert"
"testing"
)
const DefaultOuterDomain = "google.com"
var testIP2Long = []struct {
long uint32
ip string
}{
{2130706433, "127.0.0.1"},
{3927057275, "234.18.35.123"},
{2956665461, "176.59.34.117"},
}
func TestIP2long(t *testing.T) {
// ip to long
for _, v := range testIP2Long {
long, err := pgo.IP2long(v.ip)
assert.NoError(t, err)
assert.Equal(t, long, v.long, "want %d, but got %d", long, v.long)
}
// long to ip
for _, v := range testIP2Long {
ip := pgo.Long2ip(v.long)
assert.Equal(t, ip, v.ip, "want %d, but got %d", ip, v.ip)
}
}
func TestGetMxrr(t *testing.T) {
isMx, mxs, err := pgo.GetMxrr(DefaultOuterDomain)
assert.NoError(t, err)
assert.True(t, isMx)
assert.Greaterf(t, len(mxs), 0, "want len(mxs) > 0, got %d", len(mxs))
}