Newer
Older
package net
import (
"testing"
Christoph Petrausch
committed
"net"
"github.com/stretchr/testify/assert"
)
tests := []struct {
input []byte
expected uint32
}{
{
input: []byte{192, 168, 1, 5},
expected: 3232235781,
},
{
input: []byte{10, 0, 0, 0},
expected: 167772160,
},
{
input: []byte{172, 24, 5, 1},
expected: 2887255297,
},
Christoph Petrausch
committed
{
input: net.ParseIP("172.24.5.1"),
expected: 2887255297,
},
}
for _, test := range tests {
res := IPv4ToUint32(test.input)
assert.Equal(t, test.expected, res)
}
}