Adding test for binary search rank func
This commit is contained in:
parent
b867cd616a
commit
0c300d7cdd
21
algs4/src/meatballhat.com/algs4/binarysearch_test.go
Normal file
21
algs4/src/meatballhat.com/algs4/binarysearch_test.go
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user