mirror of
https://github.com/duke-git/lancet.git
synced 2026-03-01 00:35:28 +08:00
test: add unit test for EncodeByte and DecodeByte
This commit is contained in:
@@ -238,3 +238,21 @@ func TestToPointer(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(*result, 123)
|
assert.Equal(*result, 123)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEncodeByte(t *testing.T) {
|
||||||
|
assert := internal.NewAssert(t, "TestEncodeByte")
|
||||||
|
|
||||||
|
byteData, _ := EncodeByte("abc")
|
||||||
|
expected := []byte{6, 12, 0, 3, 97, 98, 99}
|
||||||
|
|
||||||
|
assert.Equal(expected, byteData)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDecodeByte(t *testing.T) {
|
||||||
|
assert := internal.NewAssert(t, "TestDecodeByte")
|
||||||
|
|
||||||
|
var obj string
|
||||||
|
byteData := []byte{6, 12, 0, 3, 97, 98, 99}
|
||||||
|
DecodeByte(byteData, &obj)
|
||||||
|
assert.Equal("abc", obj)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user