| 679 | } |
| 680 | |
| 681 | func 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 | |
| 716 | func BenchmarkU64Get(b *testing.B) { |
| 717 | a, err := array.NewU64([]int32{1, 2, 3}, []uint64{1, 2, 3}) |