diff --git a/net/helper_test.go b/net/helper_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7503a6854d951e6a97bb0674945416b5bc52bc94 --- /dev/null +++ b/net/helper_test.go @@ -0,0 +1,32 @@ +package net + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func IPv4ToUint32Test(t *testing.T) { + 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, + }, + } + + for _, test := range tests { + res := IPv4ToUint32(test.input) + assert.Equal(t, test.expected, res) + } +}