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

Function TestVarstrList

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

Source from the content-addressed store, hash-verified

198}
199
200func TestVarstrList(t *testing.T) {
201 for i := 0; i < 4; i++ {
202 // make a list of i+1 strs, each with length i+1, each made of repeating byte i
203 strs := make([][]byte, 0, i+1)
204 for j := 0; j <= i; j++ {
205 str := make([]byte, 0, i+1)
206 for k := 0; k <= i; k++ {
207 str = append(str, byte(i))
208 }
209 strs = append(strs, str)
210 }
211 var buf bytes.Buffer
212 _, err := WriteVarstrList(&buf, strs)
213 if err != nil {
214 t.Fatal(err)
215 }
216 strs2, err := ReadVarstrList(NewReader(buf.Bytes()))
217 if err != nil {
218 t.Fatal(err)
219 }
220 if !reflect.DeepEqual(strs, strs2) {
221 t.Errorf("got %v, want %v", strs2, strs)
222 }
223 }
224}
225
226func TestVarstrListWithEOF(t *testing.T) {
227 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 4

WriteVarstrListFunction · 0.85
ReadVarstrListFunction · 0.85
NewReaderFunction · 0.85
BytesMethod · 0.45

Tested by

no test coverage detected