1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
21 func int2Value(x
int) int { return x
}
22 func int2IntValue(x
int) int { return x
}
23 func int2StrValue(x
int) string { return string(x
) }
26 func elem2Value(x
interface{}) int { return x
.(int) }
27 func elem2IntValue(x
int) int { return x
}
28 func elem2StrValue(x
string) string { return x
}
31 func intf2Value(x
interface{}) int { return x
.(int) }
32 func intf2IntValue(x
interface{}) int { return x
.(int) }
33 func intf2StrValue(x
interface{}) string { return x
.(string) }
36 type VectorInterface
interface {
42 func checkSize(t
*testing
.T
, v VectorInterface
, len, cap int) {
44 t
.Errorf("%T expected len = %d; found %d", v
, len, v
.Len())
47 t
.Errorf("%T expected cap >= %d; found %d", v
, cap, v
.Cap())
52 func val(i
int) int { return i
*991 - 1234 }
55 func TestSorting(t
*testing
.T
) {
58 a
:= new(IntVector
).Resize(n
, 0)
59 for i
:= n
- 1; i
>= 0; i
-- {
63 t
.Error("int vector not sorted")
66 b
:= new(StringVector
).Resize(n
, 0)
67 for i
:= n
- 1; i
>= 0; i
-- {
68 b
.Set(i
, fmt
.Sprint(n
-1-i
))
71 t
.Error("string vector not sorted")
76 func tname(x
interface{}) string { return fmt
.Sprintf("%T: ", x
) }