package ipp import ( "bytes" "testing" "github.com/stretchr/testify/assert" ) func TestUnMarshalSinglePositiveInteger(T *testing.T) { testdata := []byte{ 0x00, 0x04, 0x66, 0x6c, 0x6f, 0x70, //flop 0x00, 0x04, 0x00, 0x0, 0x0, 0x4, } buf := bytes.NewBuffer(testdata) n, v := unmarshalSingleInteger(buf) assert.Equal(T, "flop", n, "Should be equal") assert.Equal(T, int32(4), v, "Should be equal") } func TestUnMarshalSingleNegativeInteger(T *testing.T) { testdata := []byte{ 0x00, 0x04, 0x66, 0x6c, 0x6f, 0x70, //flop 0x00, 0x04, 0xff, 0xff, 0xff, 0xfc, } buf := bytes.NewBuffer(testdata) n, v := unmarshalSingleInteger(buf) assert.Equal(T, "flop", n, "Should be equal") assert.Equal(T, int32(-4), v, "Should be equal") }