Adding test for binary search rank func

This commit is contained in:
Dan Buch 2012-11-18 20:20:07 -05:00
parent b867cd616a
commit 0c300d7cdd

View File

@ -0,0 +1,21 @@
package algs4_test
import (
"testing"
)
import (
"meatballhat.com/algs4"
)
func TestBinarySearchRank(t *testing.T) {
arr := [...]int{0, 2, 9, 14, 23}
if algs4.BinarySearchRank(9, arr[:]) != 2 {
t.Error("Failed to find 9 in", arr)
}
if algs4.BinarySearchRank(0, arr[:]) != 0 {
t.Error("Failed to find 0 in", arr)
}
}