Created
December 13, 2013 19:52
-
-
Save rdarder/7950253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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