Skip to content

Commit 16b678e

Browse files
committed
more tests
1 parent e1b8e65 commit 16b678e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

mysql/queryattributes_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package mysql
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestTypeAndFlag_string(t *testing.T) {
10+
qattr := QueryAttribute{
11+
Name: "attrname",
12+
Value: "attrvalue",
13+
}
14+
15+
tf := qattr.TypeAndFlag()
16+
require.Equal(t, []byte{0xfe, 0x0}, tf)
17+
18+
vb := qattr.ValueBytes()
19+
require.Equal(t, []byte{0x9, 0x61, 0x74, 0x74, 0x72, 0x76, 0x61, 0x6c, 0x75, 0x65}, vb)
20+
}
21+
22+
func TestTypeAndFlag_uint64(t *testing.T) {
23+
qattr := QueryAttribute{
24+
Name: "attrname",
25+
Value: uint64(12345),
26+
}
27+
28+
tf := qattr.TypeAndFlag()
29+
require.Equal(t, []byte{0x08, 0x80}, tf)
30+
31+
vb := qattr.ValueBytes()
32+
require.Equal(t, []byte{0x39, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, vb)
33+
}

0 commit comments

Comments
 (0)