| 186 | } |
| 187 | |
| 188 | func testEnumerate(t *testing.T, kv sorted.KeyValue, start, end string, want ...string) { |
| 189 | var got []string |
| 190 | it := kv.Find(start, end) |
| 191 | for it.Next() { |
| 192 | key, val := it.Key(), it.Value() |
| 193 | keyb, valb := it.KeyBytes(), it.ValueBytes() |
| 194 | if key != string(keyb) { |
| 195 | t.Errorf("Key and KeyBytes disagree: %q vs %q", key, keyb) |
| 196 | } |
| 197 | if val != string(valb) { |
| 198 | t.Errorf("Value and ValueBytes disagree: %q vs %q", val, valb) |
| 199 | } |
| 200 | if key+"v" != val { |
| 201 | t.Errorf("iterator returned unexpected pair for test: %q, %q", key, val) |
| 202 | } |
| 203 | got = append(got, val) |
| 204 | } |
| 205 | err := it.Close() |
| 206 | if err != nil { |
| 207 | t.Errorf("for enumerate of (%q, %q), Close error: %v", start, end, err) |
| 208 | } |
| 209 | if !reflect.DeepEqual(got, want) { |
| 210 | t.Errorf("for enumerate of (%q, %q), got: %q; want %q", start, end, got, want) |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | func isEmpty(t *testing.T, kv sorted.KeyValue) bool { |
| 215 | it := kv.Find("", "") |