Skip to content

Instantly share code, notes, and snippets.

@rdarder
Created December 13, 2013 19:52
Show Gist options
  • Save rdarder/7950253 to your computer and use it in GitHub Desktop.
Save rdarder/7950253 to your computer and use it in GitHub Desktop.
func TestRangeScan(t *testing.T) {
store := getLoadedStore()
testData.load()
sorted_words := sort.StringSlice(testData.words)
start, stop := sorted_words.Search("hello"), sorted_words.Search("world")
i := 0
fmt.Printf("scanning from %s to %s\n", start, stop)
for iter := store.Scan().From(str("hello")).To(str("world")).Start(); iter.Next(); i++ {
iter_word := iter.Entry().GetValue().(string)
word := testData.words[start+i]
if iter_word != word {
t.Fatalf("Expected '%s' in FullScan, got '%s' instead'", word, iter_word)
}
}
if i+start != stop+1 {
t.Fatalf("Range scanner didn't stop at [%d]='%s', stopped at [%d]='%s'",
stop, testData.words[stop], i+start, testData.words[i+start])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment