| 703 | } |
| 704 | |
| 705 | func TestStringCountBit(t *testing.T) { |
| 706 | key := []byte("bit-count") |
| 707 | callFunc := func(txn *Transaction) { |
| 708 | s, err := GetString(txn, key) |
| 709 | assert.NoError(t, err) |
| 710 | s.SetBit(4, 1) |
| 711 | } |
| 712 | MockTest(t, callFunc) |
| 713 | |
| 714 | type args struct { |
| 715 | begin int |
| 716 | end int |
| 717 | } |
| 718 | type want struct { |
| 719 | count int |
| 720 | } |
| 721 | tests := []struct { |
| 722 | name string |
| 723 | args args |
| 724 | want want |
| 725 | }{ |
| 726 | { |
| 727 | name: "one", |
| 728 | args: args{ |
| 729 | begin: 0, |
| 730 | end: 10, |
| 731 | }, |
| 732 | want: want{ |
| 733 | count: 1, |
| 734 | }, |
| 735 | }, |
| 736 | } |
| 737 | |
| 738 | for _, tt := range tests { |
| 739 | t.Run(tt.name, func(t *testing.T) { |
| 740 | callFunc := func(txn *Transaction) { |
| 741 | s, err := GetString(txn, key) |
| 742 | assert.NoError(t, err) |
| 743 | count, err := s.BitCount(tt.args.begin, tt.args.end) |
| 744 | assert.NoError(t, err) |
| 745 | assert.Equal(t, tt.want.count, count) |
| 746 | } |
| 747 | MockTest(t, callFunc) |
| 748 | }) |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | func TestStringBitPos(t *testing.T) { |
| 753 | key := []byte("bit-pos") |