summaryrefslogtreecommitdiff
path: root/libgo/go/sort/search_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/sort/search_test.go')
-rw-r--r--libgo/go/sort/search_test.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/libgo/go/sort/search_test.go b/libgo/go/sort/search_test.go
index 939f66af380..07295ffa976 100644
--- a/libgo/go/sort/search_test.go
+++ b/libgo/go/sort/search_test.go
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sort
-
-import "testing"
+package sort_test
+import (
+ . "sort"
+ "testing"
+)
func f(a []int, x int) func(int) bool {
return func(i int) bool {
@@ -13,7 +15,6 @@ func f(a []int, x int) func(int) bool {
}
}
-
var data = []int{0: -10, 1: -5, 2: 0, 3: 1, 4: 2, 5: 3, 6: 5, 7: 7, 8: 11, 9: 100, 10: 100, 11: 100, 12: 1000, 13: 10000}
var tests = []struct {
@@ -46,7 +47,6 @@ var tests = []struct {
{"overflow", 2e9, func(i int) bool { return false }, 2e9},
}
-
func TestSearch(t *testing.T) {
for _, e := range tests {
i := Search(e.n, e.f)
@@ -56,7 +56,6 @@ func TestSearch(t *testing.T) {
}
}
-
// log2 computes the binary logarithm of x, rounded up to the next integer.
// (log2(0) == 0, log2(1) == 0, log2(2) == 1, log2(3) == 2, etc.)
//
@@ -70,7 +69,6 @@ func log2(x int) int {
return n
}
-
func TestSearchEfficiency(t *testing.T) {
n := 100
step := 1
@@ -93,7 +91,6 @@ func TestSearchEfficiency(t *testing.T) {
}
}
-
// Smoke tests for convenience wrappers - not comprehensive.
var fdata = []float64{0: -3.14, 1: 0, 2: 1, 3: 2, 4: 1000.7}
@@ -107,12 +104,11 @@ var wrappertests = []struct {
{"SearchInts", SearchInts(data, 11), 8},
{"SearchFloat64s", SearchFloat64s(fdata, 2.1), 4},
{"SearchStrings", SearchStrings(sdata, ""), 0},
- {"IntArray.Search", IntArray(data).Search(0), 2},
- {"Float64Array.Search", Float64Array(fdata).Search(2.0), 3},
- {"StringArray.Search", StringArray(sdata).Search("x"), 3},
+ {"IntSlice.Search", IntSlice(data).Search(0), 2},
+ {"Float64Slice.Search", Float64Slice(fdata).Search(2.0), 3},
+ {"StringSlice.Search", StringSlice(sdata).Search("x"), 3},
}
-
func TestSearchWrappers(t *testing.T) {
for _, e := range wrappertests {
if e.result != e.i {
@@ -121,7 +117,6 @@ func TestSearchWrappers(t *testing.T) {
}
}
-
// Abstract exhaustive test: all sizes up to 100,
// all possible return values. If there are any small
// corner cases, this test exercises them.