MCPcopy Create free account
hub / github.com/mpolden/echoip / TestToDecimal

Function TestToDecimal

iputil/iputil_test.go:9–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestToDecimal(t *testing.T) {
10 var msb = new(big.Int)
11 msb, _ = msb.SetString("80000000000000000000000000000000", 16)
12
13 var tests = []struct {
14 in string
15 out *big.Int
16 }{
17 {"127.0.0.1", big.NewInt(2130706433)},
18 {"::1", big.NewInt(1)},
19 {"8000::", msb},
20 }
21 for _, tt := range tests {
22 i := ToDecimal(net.ParseIP(tt.in))
23 if tt.out.Cmp(i) != 0 {
24 t.Errorf("Expected %d, got %d for IP %s", tt.out, i, tt.in)
25 }
26 }
27}

Callers

nothing calls this directly

Calls 1

ToDecimalFunction · 0.85

Tested by

no test coverage detected