MCPcopy
hub / github.com/perkeep/perkeep / testEnumerate

Function testEnumerate

pkg/sorted/kvtest/kvtest.go:188–212  ·  view source on GitHub ↗
(t *testing.T, kv sorted.KeyValue, start, end string, want ...string)

Source from the content-addressed store, hash-verified

186}
187
188func 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
214func isEmpty(t *testing.T, kv sorted.KeyValue) bool {
215 it := kv.Find("", "")

Callers 1

TestSortedFunction · 0.85

Calls 7

FindMethod · 0.65
NextMethod · 0.65
KeyMethod · 0.65
ValueMethod · 0.65
KeyBytesMethod · 0.65
ValueBytesMethod · 0.65
CloseMethod · 0.65

Tested by 1

TestSortedFunction · 0.68