(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func TestMergedIterator_complex(t *testing.T) { |
| 115 | ctrl := gomock.NewController(t) |
| 116 | defer ctrl.Finish() |
| 117 | |
| 118 | it1 := generateIterator(ctrl, map[uint32][]byte{ |
| 119 | 1: []byte("value1"), |
| 120 | 3: []byte("value3"), |
| 121 | 10: []byte("value10"), |
| 122 | }) |
| 123 | it2 := generateIterator(ctrl, map[uint32][]byte{ |
| 124 | 10: []byte("value10"), |
| 125 | 30: []byte("value30"), |
| 126 | 40: []byte("value40"), |
| 127 | }) |
| 128 | it3 := generateIterator(ctrl, map[uint32][]byte{ |
| 129 | 1: []byte("value1"), |
| 130 | 10: []byte("value10"), |
| 131 | }) |
| 132 | it4 := generateIterator(ctrl, map[uint32][]byte{ |
| 133 | 10: []byte("value10"), |
| 134 | 30: []byte("value30"), |
| 135 | 100: []byte("value100"), |
| 136 | }) |
| 137 | expects := map[uint32][]byte{ |
| 138 | uint32(1): []byte("value1"), |
| 139 | uint32(3): []byte("value3"), |
| 140 | uint32(10): []byte("value10"), |
| 141 | uint32(30): []byte("value30"), |
| 142 | uint32(40): []byte("value40"), |
| 143 | uint32(100): []byte("value100"), |
| 144 | } |
| 145 | keys := []uint32{1, 1, 3, 10, 10, 10, 10, 30, 30, 40, 100} |
| 146 | mergedIt := NewMergedIterator([]Iterator{it1, it2, it3, it4}) |
| 147 | i := 0 |
| 148 | for mergedIt.HasNext() { |
| 149 | assert.Equal(t, keys[i], mergedIt.Key()) |
| 150 | assert.Equal(t, expects[keys[i]], mergedIt.Value()) |
| 151 | i++ |
| 152 | } |
| 153 | assert.Equal(t, len(keys), i) |
| 154 | } |
| 155 | |
| 156 | func generateIterator(ctrl *gomock.Controller, values map[uint32][]byte) *MockIterator { |
| 157 | it1 := NewMockIterator(ctrl) |
nothing calls this directly
no test coverage detected