MCPcopy
hub / github.com/TarsCloud/TarsGo / TestUint16

Function TestUint16

tars/protocol/codec/codec_test.go:58–76  ·  view source on GitHub ↗

TestUint16 tests the read and write of the int16 type.

(t *testing.T)

Source from the content-addressed store, hash-verified

56
57// TestUint16 tests the read and write of the int16 type.
58func TestUint16(t *testing.T) {
59 for tag := 0; tag < 250; tag += 10 {
60 for i := 0; i < math.MaxUint16; i++ {
61 b := NewBuffer()
62 err := b.WriteUint16(uint16(i), byte(tag))
63 if err != nil {
64 t.Error(err)
65 }
66 var data uint16
67 err = r(b).ReadUint16(&data, byte(tag), true)
68 if err != nil {
69 t.Error(err)
70 }
71 if data != uint16(i) {
72 t.Error("no eq.")
73 }
74 }
75 }
76}
77
78// TestInt16 tests the read and write of the int16 type.
79func TestInt16(t *testing.T) {

Callers

nothing calls this directly

Calls 5

WriteUint16Method · 0.95
NewBufferFunction · 0.85
rFunction · 0.85
ReadUint16Method · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected