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

Function TestU32EncodeDecodeBig

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

Source from the content-addressed store, hash-verified

443}
444
445func TestU32EncodeDecodeBig(t *testing.T) {
446
447 n := 102400
448 step := 2
449 indexes := []int32{}
450 elts := []uint32{}
451
452 for i := 0; i < n; i += step {
453 indexes = append(indexes, int32(i))
454 elts = append(elts, uint32(i))
455 }
456
457 a, err := array.NewU32(indexes, elts)
458 if err != nil {
459 t.Errorf("expect no error but: %s", err)
460 }
461
462 rst, err := proto.Marshal(a)
463 if err != nil {
464 t.Errorf("expect no error but: %s", err)
465 }
466
467 b := &array.U32{}
468 err = proto.Unmarshal(rst, b)
469 if err != nil {
470 t.Errorf("expect no error but: %s", err)
471 }
472
473 // proto pollute this field
474 a.XXX_sizecache = 0
475 if !reflect.DeepEqual(a, b) {
476 t.Fatalf("compare: a b: %v", pretty.Diff(a, b))
477 }
478}
479
480func BenchmarkU32Get(b *testing.B) {
481 a, err := array.NewU32([]int32{1, 2, 3}, []uint32{1, 2, 3})

Callers

nothing calls this directly

Calls 3

NewU32Function · 0.92
MarshalMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected