github.com/batchcorp/thrift-iterator@v0.0.0-20220918180557-4c4a158fc6e9/test/level_0/uint16_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 "github.com/stretchr/testify/require" 6 "github.com/batchcorp/thrift-iterator/test" 7 ) 8 9 func Test_decode_uint16(t *testing.T) { 10 should := require.New(t) 11 for _, c := range test.Combinations { 12 buf, proto := c.CreateProtocol() 13 proto.WriteI16(1024) 14 iter := c.CreateIterator(buf.Bytes()) 15 should.Equal(uint16(1024), iter.ReadUint16()) 16 } 17 } 18 19 func Test_unmarshal_uint16(t *testing.T) { 20 should := require.New(t) 21 for _, c := range test.UnmarshalCombinations { 22 buf, proto := c.CreateProtocol() 23 proto.WriteI16(1024) 24 var val uint16 25 should.NoError(c.Unmarshal(buf.Bytes(), &val)) 26 should.Equal(uint16(1024), val) 27 } 28 } 29 30 func Test_encode_uint16(t *testing.T) { 31 should := require.New(t) 32 for _, c := range test.Combinations { 33 stream := c.CreateStream() 34 stream.WriteUint16(1024) 35 iter := c.CreateIterator(stream.Buffer()) 36 should.Equal(uint16(1024), iter.ReadUint16()) 37 } 38 } 39 40 func Test_marshal_uint16(t *testing.T) { 41 should := require.New(t) 42 for _, c := range test.MarshalCombinations { 43 output, err := c.Marshal(uint16(1024)) 44 should.NoError(err) 45 iter := c.CreateIterator(output) 46 should.Equal(uint16(1024), iter.ReadUint16()) 47 } 48 }