MCPcopy
hub / github.com/openacid/slim / TestI64EncodeDecodeBig

Function TestI64EncodeDecodeBig

array/int_test.go:1389–1422  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1387}
1388
1389func TestI64EncodeDecodeBig(t *testing.T) {
1390
1391 n := 102400
1392 step := 2
1393 indexes := []int32{}
1394 elts := []int64{}
1395
1396 for i := 0; i < n; i += step {
1397 indexes = append(indexes, int32(i))
1398 elts = append(elts, int64(i))
1399 }
1400
1401 a, err := array.NewI64(indexes, elts)
1402 if err != nil {
1403 t.Errorf("expect no error but: %s", err)
1404 }
1405
1406 rst, err := proto.Marshal(a)
1407 if err != nil {
1408 t.Errorf("expect no error but: %s", err)
1409 }
1410
1411 b := &array.I64{}
1412 err = proto.Unmarshal(rst, b)
1413 if err != nil {
1414 t.Errorf("expect no error but: %s", err)
1415 }
1416
1417 // proto pollute this field
1418 a.XXX_sizecache = 0
1419 if !reflect.DeepEqual(a, b) {
1420 t.Fatalf("compare: a b: %v", pretty.Diff(a, b))
1421 }
1422}
1423
1424func BenchmarkI64Get(b *testing.B) {
1425 a, err := array.NewI64([]int32{1, 2, 3}, []int64{1, 2, 3})

Callers

nothing calls this directly

Calls 3

NewI64Function · 0.92
MarshalMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected