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

Function TestU64EncodeDecodeBig

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

Source from the content-addressed store, hash-verified

679}
680
681func TestU64EncodeDecodeBig(t *testing.T) {
682
683 n := 102400
684 step := 2
685 indexes := []int32{}
686 elts := []uint64{}
687
688 for i := 0; i < n; i += step {
689 indexes = append(indexes, int32(i))
690 elts = append(elts, uint64(i))
691 }
692
693 a, err := array.NewU64(indexes, elts)
694 if err != nil {
695 t.Errorf("expect no error but: %s", err)
696 }
697
698 rst, err := proto.Marshal(a)
699 if err != nil {
700 t.Errorf("expect no error but: %s", err)
701 }
702
703 b := &array.U64{}
704 err = proto.Unmarshal(rst, b)
705 if err != nil {
706 t.Errorf("expect no error but: %s", err)
707 }
708
709 // proto pollute this field
710 a.XXX_sizecache = 0
711 if !reflect.DeepEqual(a, b) {
712 t.Fatalf("compare: a b: %v", pretty.Diff(a, b))
713 }
714}
715
716func BenchmarkU64Get(b *testing.B) {
717 a, err := array.NewU64([]int32{1, 2, 3}, []uint64{1, 2, 3})

Callers

nothing calls this directly

Calls 3

NewU64Function · 0.92
MarshalMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected