github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/u32/u32_test.go (about) 1 package u32 2 3 import ( 4 "encoding/binary" 5 "math" 6 "testing" 7 8 "github.com/bananabytelabs/wazero/internal/testing/require" 9 ) 10 11 func TestBytes(t *testing.T) { 12 tests := []struct { 13 name string 14 input uint32 15 }{ 16 { 17 name: "zero", 18 input: 0, 19 }, 20 { 21 name: "half", 22 input: math.MaxInt32, 23 }, 24 { 25 name: "max", 26 input: math.MaxUint32, 27 }, 28 } 29 30 for _, tt := range tests { 31 tc := tt 32 33 t.Run(tc.name, func(t *testing.T) { 34 expected := make([]byte, 4) 35 binary.LittleEndian.PutUint32(expected, tc.input) 36 require.Equal(t, expected, LeBytes(tc.input)) 37 }) 38 } 39 }