|
@ -66,7 +66,6 @@ func TestPrefixIteratorMatches1N(t *testing.T) { |
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
itr.Seek(bz("a/1")) |
|
|
|
|
|
|
|
|
|
|
|
checkValid(t, itr, true) |
|
|
checkValid(t, itr, true) |
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
@ -82,32 +81,6 @@ func TestPrefixIteratorMatches1N(t *testing.T) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Search for a/1, fail by too much Prev()
|
|
|
|
|
|
func TestPrefixIteratorMatches1P(t *testing.T) { |
|
|
|
|
|
for backend, _ := range backends { |
|
|
|
|
|
t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) { |
|
|
|
|
|
db := newTempDB(t, backend) |
|
|
|
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
|
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
|
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
|
|
|
itr.Seek(bz("a/1")) |
|
|
|
|
|
|
|
|
|
|
|
checkValid(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
|
|
|
checkNext(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
|
|
|
checkPrev(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
|
|
|
|
|
|
|
|
|
// Bad!
|
|
|
|
|
|
checkPrev(t, itr, false) |
|
|
|
|
|
|
|
|
|
|
|
// Once invalid...
|
|
|
|
|
|
checkInvalid(t, itr) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Search for a/2, fail by too much Next()
|
|
|
// Search for a/2, fail by too much Next()
|
|
|
func TestPrefixIteratorMatches2N(t *testing.T) { |
|
|
func TestPrefixIteratorMatches2N(t *testing.T) { |
|
|
for backend, _ := range backends { |
|
|
for backend, _ := range backends { |
|
@ -116,41 +89,15 @@ func TestPrefixIteratorMatches2N(t *testing.T) { |
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
itr.Seek(bz("a/2")) |
|
|
|
|
|
|
|
|
|
|
|
checkValid(t, itr, true) |
|
|
checkValid(t, itr, true) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
|
|
|
checkPrev(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
checkNext(t, itr, true) |
|
|
checkNext(t, itr, true) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
|
|
|
|
|
|
|
|
|
// Bad!
|
|
|
|
|
|
checkNext(t, itr, false) |
|
|
|
|
|
|
|
|
|
|
|
// Once invalid...
|
|
|
|
|
|
checkInvalid(t, itr) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Search for a/2, fail by too much Prev()
|
|
|
|
|
|
func TestPrefixIteratorMatches2P(t *testing.T) { |
|
|
|
|
|
for backend, _ := range backends { |
|
|
|
|
|
t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) { |
|
|
|
|
|
db := newTempDB(t, backend) |
|
|
|
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
|
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
|
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
|
|
|
itr.Seek(bz("a/2")) |
|
|
|
|
|
|
|
|
|
|
|
checkValid(t, itr, true) |
|
|
checkValid(t, itr, true) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
checkPrev(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
|
|
|
|
|
|
|
|
|
// Bad!
|
|
|
// Bad!
|
|
|
checkPrev(t, itr, false) |
|
|
|
|
|
|
|
|
checkNext(t, itr, false) |
|
|
|
|
|
|
|
|
// Once invalid...
|
|
|
// Once invalid...
|
|
|
checkInvalid(t, itr) |
|
|
checkInvalid(t, itr) |
|
@ -166,11 +113,8 @@ func TestPrefixIteratorMatches3N(t *testing.T) { |
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
itr.Seek(bz("a/3")) |
|
|
|
|
|
|
|
|
|
|
|
checkValid(t, itr, true) |
|
|
checkValid(t, itr, true) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
|
|
|
checkPrev(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
checkNext(t, itr, true) |
|
|
checkNext(t, itr, true) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
@ -183,27 +127,3 @@ func TestPrefixIteratorMatches3N(t *testing.T) { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Search for a/3, fail by too much Prev()
|
|
|
|
|
|
func TestPrefixIteratorMatches3P(t *testing.T) { |
|
|
|
|
|
for backend, _ := range backends { |
|
|
|
|
|
t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) { |
|
|
|
|
|
db := newTempDB(t, backend) |
|
|
|
|
|
db.SetSync(bz("a/1"), bz("value_1")) |
|
|
|
|
|
db.SetSync(bz("a/3"), bz("value_3")) |
|
|
|
|
|
itr := IteratePrefix(db, []byte("a/")) |
|
|
|
|
|
itr.Seek(bz("a/3")) |
|
|
|
|
|
|
|
|
|
|
|
checkValid(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/3"), bz("value_3")) |
|
|
|
|
|
checkPrev(t, itr, true) |
|
|
|
|
|
checkItem(t, itr, bz("a/1"), bz("value_1")) |
|
|
|
|
|
|
|
|
|
|
|
// Bad!
|
|
|
|
|
|
checkPrev(t, itr, false) |
|
|
|
|
|
|
|
|
|
|
|
// Once invalid...
|
|
|
|
|
|
checkInvalid(t, itr) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|