MCPcopy Create free account
hub / github.com/chain/Core / TestVarstring31

Function TestVarstring31

encoding/blockchain/blockchain_test.go:143–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

141}
142
143func TestVarstring31(t *testing.T) {
144 s := []byte{10, 11, 12}
145 b := new(bytes.Buffer)
146 _, err := WriteVarstr31(b, s)
147 if err != nil {
148 t.Fatal(err)
149 }
150 want := []byte{3, 10, 11, 12}
151 if !bytes.Equal(b.Bytes(), want) {
152 t.Errorf("got %x, want %x", b.Bytes(), want)
153 }
154 s, err = ReadVarstr31(NewReader(want))
155 if err != nil {
156 t.Fatal(err)
157 }
158 want = []byte{10, 11, 12}
159 if !bytes.Equal(s, want) {
160 t.Errorf("got %x, expected %x", s, want)
161 }
162}
163
164func TestEmptyVarstring31(t *testing.T) {
165 s := []byte{}

Callers

nothing calls this directly

Calls 5

WriteVarstr31Function · 0.85
ReadVarstr31Function · 0.85
NewReaderFunction · 0.85
EqualMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected