1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 06:32:28 +08:00

test: add unit test for EncodeByte and DecodeByte

This commit is contained in:
dudaodong
2022-08-26 10:47:25 +08:00
parent b30f4a7bab
commit f49f75b371

View File

@@ -238,3 +238,21 @@ func TestToPointer(t *testing.T) {
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)
}