Add integer attribute type.
Merges some common code between integer and enum.
Enum can now bw a set.
Add valuer must take a interface{} in addValue since it can be different types.
This commit is contained in:
38
packages/ipp/integer_test.go
Normal file
38
packages/ipp/integer_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user