1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:24:40 -07:00

Cleanup: remove Exp ending in identifiers

as it is not needed anymore (only one impl.
of vector package).

Makefile, vector_test.go, and nogen_test.go
were modified manually (find/replace), the
other files (intvector_test.go, strinvector_test.go
are generated).

Runs all tests.

R=r
https://golang.org/cl/182041
This commit is contained in:
Robert Griesemer 2009-12-22 18:45:36 -08:00
parent 8c7d001602
commit a0862ea568
5 changed files with 198 additions and 198 deletions

View File

@ -28,19 +28,19 @@ generate: vector.go vector_test.go
| gofmt -r='elem2Value -> elem2IntValue'\
| gofmt -r='intf2Value -> intf2IntValue'\
| gofmt -r='int2Value -> int2IntValue'\
| gofmt -r='TestZeroLenExp -> TestIntZeroLenExp'\
| gofmt -r='TestResizeExp -> TestIntResizeExp'\
| gofmt -r='TestResize2Exp -> TestIntResize2Exp'\
| gofmt -r='checkZeroExp -> checkIntZeroExp'\
| gofmt -r='TestTrailingElementsExp -> TestIntTrailingElementsExp'\
| gofmt -r='TestAccessExp -> TestIntAccessExp'\
| gofmt -r='TestInsertDeleteClearExp -> TestIntInsertDeleteClearExp'\
| gofmt -r='verify_sliceExp -> verify_sliceIntExp'\
| gofmt -r='verify_patternExp -> verify_patternIntExp'\
| gofmt -r='make_vectorExp -> make_vectorIntExp'\
| gofmt -r='TestInsertVectorExp -> TestIntInsertVectorExp'\
| gofmt -r='TestDoExp -> TestIntDoExp'\
| gofmt -r='TestIterExp -> TestIntIterExp'\
| gofmt -r='TestZeroLen -> TestIntZeroLen'\
| gofmt -r='TestResize -> TestIntResize'\
| gofmt -r='TestResize2 -> TestIntResize2'\
| gofmt -r='checkZero -> checkIntZero'\
| gofmt -r='TestTrailingElements -> TestIntTrailingElements'\
| gofmt -r='TestAccess -> TestIntAccess'\
| gofmt -r='TestInsertDeleteClear -> TestIntInsertDeleteClear'\
| gofmt -r='verify_slice -> verify_sliceInt'\
| gofmt -r='verify_pattern -> verify_patternInt'\
| gofmt -r='make_vector -> make_vectorInt'\
| gofmt -r='TestInsertVector -> TestIntInsertVector'\
| gofmt -r='TestDo -> TestIntDo'\
| gofmt -r='TestIter -> TestIntIter'\
| gofmt -r='TestVectorData -> TestIntVectorData'\
> intvector_test.go\
@ -50,19 +50,19 @@ generate: vector.go vector_test.go
| gofmt -r='int2Value -> int2StrValue'\
| gofmt -r='intf2Value -> intf2StrValue'\
| gofmt -r='elem2Value -> elem2StrValue'\
| gofmt -r='TestZeroLenExp -> TestStrZeroLenExp'\
| gofmt -r='TestResizeExp -> TestStrResizeExp'\
| gofmt -r='TestResize2Exp -> TestStrResize2Exp'\
| gofmt -r='checkZeroExp -> checkStrZeroExp'\
| gofmt -r='TestTrailingElementsExp -> TestStrTrailingElementsExp'\
| gofmt -r='TestAccessExp -> TestStrAccessExp'\
| gofmt -r='TestInsertDeleteClearExp -> TestStrInsertDeleteClearExp'\
| gofmt -r='verify_sliceExp -> verify_sliceStrExp'\
| gofmt -r='verify_patternExp -> verify_patternStrExp'\
| gofmt -r='make_vectorExp -> make_vectorStrExp'\
| gofmt -r='TestInsertVectorExp -> TestStrInsertVectorExp'\
| gofmt -r='TestDoExp -> TestStrDoExp'\
| gofmt -r='TestIterExp -> TestStrIterExp'\
| gofmt -r='TestZeroLen -> TestStrZeroLen'\
| gofmt -r='TestResize -> TestStrResize'\
| gofmt -r='TestResize2 -> TestStrResize2'\
| gofmt -r='checkZero -> checkStrZero'\
| gofmt -r='TestTrailingElements -> TestStrTrailingElements'\
| gofmt -r='TestAccess -> TestStrAccess'\
| gofmt -r='TestInsertDeleteClear -> TestStrInsertDeleteClear'\
| gofmt -r='verify_slice -> verify_sliceStr'\
| gofmt -r='verify_pattern -> verify_patternStr'\
| gofmt -r='make_vector -> make_vectorStr'\
| gofmt -r='TestInsertVector -> TestStrInsertVector'\
| gofmt -r='TestDo -> TestStrDo'\
| gofmt -r='TestIter -> TestStrIter'\
| gofmt -r='TestVectorData -> TestStrVectorData'\
> stringvector_test.go

View File

@ -10,7 +10,7 @@ package vector
import "testing"
func TestIntZeroLenExp(t *testing.T) {
func TestIntZeroLen(t *testing.T) {
a := new(IntVector)
if a.Len() != 0 {
t.Errorf("%T: B1) expected 0, got %d", a, a.Len())
@ -28,28 +28,28 @@ func TestIntZeroLenExp(t *testing.T) {
}
func TestIntResizeExp(t *testing.T) {
func TestIntResize(t *testing.T) {
var a IntVector
checkSizeExp(t, &a, 0, 0)
checkSizeExp(t, a.Resize(0, 5), 0, 5)
checkSizeExp(t, a.Resize(1, 0), 1, 5)
checkSizeExp(t, a.Resize(10, 0), 10, 10)
checkSizeExp(t, a.Resize(5, 0), 5, 10)
checkSizeExp(t, a.Resize(3, 8), 3, 10)
checkSizeExp(t, a.Resize(0, 100), 0, 100)
checkSizeExp(t, a.Resize(11, 100), 11, 100)
checkSize(t, &a, 0, 0)
checkSize(t, a.Resize(0, 5), 0, 5)
checkSize(t, a.Resize(1, 0), 1, 5)
checkSize(t, a.Resize(10, 0), 10, 10)
checkSize(t, a.Resize(5, 0), 5, 10)
checkSize(t, a.Resize(3, 8), 3, 10)
checkSize(t, a.Resize(0, 100), 0, 100)
checkSize(t, a.Resize(11, 100), 11, 100)
}
func TestIntResize2Exp(t *testing.T) {
func TestIntResize2(t *testing.T) {
var a IntVector
checkSizeExp(t, &a, 0, 0)
checkSize(t, &a, 0, 0)
a.Push(int2IntValue(1))
a.Push(int2IntValue(2))
a.Push(int2IntValue(3))
a.Push(int2IntValue(4))
checkSizeExp(t, &a, 4, 4)
checkSizeExp(t, a.Resize(10, 0), 10, 10)
checkSize(t, &a, 4, 4)
checkSize(t, a.Resize(10, 0), 10, 10)
for i := 4; i < a.Len(); i++ {
if a.At(i) != intzero {
t.Errorf("%T: expected a.At(%d) == %v; found %v!", a, i, intzero, a.At(i))
@ -63,7 +63,7 @@ func TestIntResize2Exp(t *testing.T) {
}
func checkIntZeroExp(t *testing.T, a *IntVector, i int) {
func checkIntZero(t *testing.T, a *IntVector, i int) {
for j := 0; j < i; j++ {
if a.At(j) == intzero {
t.Errorf("%T: 1 expected a.At(%d) == %d; found %v", a, j, j, a.At(j))
@ -83,45 +83,45 @@ func checkIntZeroExp(t *testing.T, a *IntVector, i int) {
}
func TestIntTrailingElementsExp(t *testing.T) {
func TestIntTrailingElements(t *testing.T) {
var a IntVector
for i := 0; i < 10; i++ {
a.Push(int2IntValue(i + 1))
}
checkIntZeroExp(t, &a, 10)
checkSizeExp(t, &a, 10, 16)
checkSizeExp(t, a.Resize(5, 0), 5, 16)
checkSizeExp(t, a.Resize(10, 0), 10, 16)
checkIntZeroExp(t, &a, 5)
checkIntZero(t, &a, 10)
checkSize(t, &a, 10, 16)
checkSize(t, a.Resize(5, 0), 5, 16)
checkSize(t, a.Resize(10, 0), 10, 16)
checkIntZero(t, &a, 5)
}
func TestIntAccessExp(t *testing.T) {
func TestIntAccess(t *testing.T) {
const n = 100
var a IntVector
a.Resize(n, 0)
for i := 0; i < n; i++ {
a.Set(i, int2IntValue(valExp(i)))
a.Set(i, int2IntValue(val(i)))
}
for i := 0; i < n; i++ {
if elem2IntValue(a.At(i)) != int2IntValue(valExp(i)) {
if elem2IntValue(a.At(i)) != int2IntValue(val(i)) {
t.Error(i)
}
}
var b IntVector
b.Resize(n, 0)
for i := 0; i < n; i++ {
b[i] = int2IntValue(valExp(i))
b[i] = int2IntValue(val(i))
}
for i := 0; i < n; i++ {
if elem2IntValue(b[i]) != int2IntValue(valExp(i)) {
if elem2IntValue(b[i]) != int2IntValue(val(i)) {
t.Error(i)
}
}
}
func TestIntInsertDeleteClearExp(t *testing.T) {
func TestIntInsertDeleteClear(t *testing.T) {
const n = 100
var a IntVector
@ -132,19 +132,19 @@ func TestIntInsertDeleteClearExp(t *testing.T) {
if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i)
}
a.Insert(0, int2IntValue(valExp(i)))
if elem2IntValue(a.Last()) != int2IntValue(valExp(0)) {
a.Insert(0, int2IntValue(val(i)))
if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
t.Error("T%: B", a)
}
}
for i := n - 1; i >= 0; i-- {
if elem2IntValue(a.Last()) != int2IntValue(valExp(0)) {
if elem2IntValue(a.Last()) != int2IntValue(val(0)) {
t.Error("T%: C", a)
}
if elem2IntValue(a.At(0)) != int2IntValue(valExp(i)) {
if elem2IntValue(a.At(0)) != int2IntValue(val(i)) {
t.Error("T%: D", a)
}
if elem2IntValue(a[0]) != int2IntValue(valExp(i)) {
if elem2IntValue(a[0]) != int2IntValue(val(i)) {
t.Error("T%: D2", a)
}
a.Delete(0)
@ -163,14 +163,14 @@ func TestIntInsertDeleteClearExp(t *testing.T) {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a))
}
for i := 0; i < n; i++ {
a.Push(int2IntValue(valExp(i)))
a.Push(int2IntValue(val(i)))
if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
}
if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1)
}
if elem2IntValue(a.Last()) != int2IntValue(valExp(i)) {
if elem2IntValue(a.Last()) != int2IntValue(val(i)) {
t.Error("T%: H", a)
}
}
@ -186,7 +186,7 @@ func TestIntInsertDeleteClearExp(t *testing.T) {
for j := 0; j < m; j++ {
a.Push(int2IntValue(j))
for i := 0; i < n; i++ {
x := valExp(i)
x := val(i)
a.Push(int2IntValue(x))
if elem2IntValue(a.Pop()) != int2IntValue(x) {
t.Error("T%: J", a)
@ -208,7 +208,7 @@ func TestIntInsertDeleteClearExp(t *testing.T) {
}
func verify_sliceIntExp(t *testing.T, x *IntVector, elt, i, j int) {
func verify_sliceInt(t *testing.T, x *IntVector, elt, i, j int) {
for k := i; k < j; k++ {
if elem2IntValue(x.At(k)) != int2IntValue(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2IntValue(x.At(k)), int2IntValue(elt))
@ -224,7 +224,7 @@ func verify_sliceIntExp(t *testing.T, x *IntVector, elt, i, j int) {
}
func verify_patternIntExp(t *testing.T, x *IntVector, a, b, c int) {
func verify_patternInt(t *testing.T, x *IntVector, a, b, c int) {
n := a + b + c
if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n)
@ -232,13 +232,13 @@ func verify_patternIntExp(t *testing.T, x *IntVector, a, b, c int) {
if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n)
}
verify_sliceIntExp(t, x, 0, 0, a)
verify_sliceIntExp(t, x, 1, a, a+b)
verify_sliceIntExp(t, x, 0, a+b, n)
verify_sliceInt(t, x, 0, 0, a)
verify_sliceInt(t, x, 1, a, a+b)
verify_sliceInt(t, x, 0, a+b, n)
}
func make_vectorIntExp(elt, len int) *IntVector {
func make_vectorInt(elt, len int) *IntVector {
x := new(IntVector).Resize(len, 0)
for i := 0; i < len; i++ {
x.Set(i, int2IntValue(elt))
@ -247,31 +247,31 @@ func make_vectorIntExp(elt, len int) *IntVector {
}
func TestIntInsertVectorExp(t *testing.T) {
func TestIntInsertVector(t *testing.T) {
// 1
a := make_vectorIntExp(0, 0)
b := make_vectorIntExp(1, 10)
a := make_vectorInt(0, 0)
b := make_vectorInt(1, 10)
a.InsertVector(0, b)
verify_patternIntExp(t, a, 0, 10, 0)
verify_patternInt(t, a, 0, 10, 0)
// 2
a = make_vectorIntExp(0, 10)
b = make_vectorIntExp(1, 0)
a = make_vectorInt(0, 10)
b = make_vectorInt(1, 0)
a.InsertVector(5, b)
verify_patternIntExp(t, a, 5, 0, 5)
verify_patternInt(t, a, 5, 0, 5)
// 3
a = make_vectorIntExp(0, 10)
b = make_vectorIntExp(1, 3)
a = make_vectorInt(0, 10)
b = make_vectorInt(1, 3)
a.InsertVector(3, b)
verify_patternIntExp(t, a, 3, 3, 7)
verify_patternInt(t, a, 3, 3, 7)
// 4
a = make_vectorIntExp(0, 10)
b = make_vectorIntExp(1, 1000)
a = make_vectorInt(0, 10)
b = make_vectorInt(1, 1000)
a.InsertVector(8, b)
verify_patternIntExp(t, a, 8, 1000, 2)
verify_patternInt(t, a, 8, 1000, 2)
}
func TestIntDoExp(t *testing.T) {
func TestIntDo(t *testing.T) {
const n = 25
const salt = 17
a := new(IntVector).Resize(n, 0)
@ -326,7 +326,7 @@ func TestIntDoExp(t *testing.T) {
}
func TestIntIterExp(t *testing.T) {
func TestIntIter(t *testing.T) {
const Len = 100
x := new(IntVector).Resize(Len, 0)
for i := 0; i < Len; i++ {

View File

@ -33,13 +33,13 @@ func intf2IntValue(x interface{}) int { return x.(int) }
func intf2StrValue(x interface{}) string { return x.(string) }
type VectorInterfaceExp interface {
type VectorInterface interface {
Len() int
Cap() int
}
func checkSizeExp(t *testing.T, v VectorInterfaceExp, len, cap int) {
func checkSize(t *testing.T, v VectorInterface, len, cap int) {
if v.Len() != len {
t.Errorf("%T expected len = %d; found %d", v, len, v.Len())
}
@ -49,10 +49,10 @@ func checkSizeExp(t *testing.T, v VectorInterfaceExp, len, cap int) {
}
func valExp(i int) int { return i*991 - 1234 }
func val(i int) int { return i*991 - 1234 }
func TestSortingExp(t *testing.T) {
func TestSorting(t *testing.T) {
const n = 100
a := new(IntVector).Resize(n, 0)

View File

@ -10,7 +10,7 @@ package vector
import "testing"
func TestStrZeroLenExp(t *testing.T) {
func TestStrZeroLen(t *testing.T) {
a := new(StringVector)
if a.Len() != 0 {
t.Errorf("%T: B1) expected 0, got %d", a, a.Len())
@ -28,28 +28,28 @@ func TestStrZeroLenExp(t *testing.T) {
}
func TestStrResizeExp(t *testing.T) {
func TestStrResize(t *testing.T) {
var a StringVector
checkSizeExp(t, &a, 0, 0)
checkSizeExp(t, a.Resize(0, 5), 0, 5)
checkSizeExp(t, a.Resize(1, 0), 1, 5)
checkSizeExp(t, a.Resize(10, 0), 10, 10)
checkSizeExp(t, a.Resize(5, 0), 5, 10)
checkSizeExp(t, a.Resize(3, 8), 3, 10)
checkSizeExp(t, a.Resize(0, 100), 0, 100)
checkSizeExp(t, a.Resize(11, 100), 11, 100)
checkSize(t, &a, 0, 0)
checkSize(t, a.Resize(0, 5), 0, 5)
checkSize(t, a.Resize(1, 0), 1, 5)
checkSize(t, a.Resize(10, 0), 10, 10)
checkSize(t, a.Resize(5, 0), 5, 10)
checkSize(t, a.Resize(3, 8), 3, 10)
checkSize(t, a.Resize(0, 100), 0, 100)
checkSize(t, a.Resize(11, 100), 11, 100)
}
func TestStrResize2Exp(t *testing.T) {
func TestStrResize2(t *testing.T) {
var a StringVector
checkSizeExp(t, &a, 0, 0)
checkSize(t, &a, 0, 0)
a.Push(int2StrValue(1))
a.Push(int2StrValue(2))
a.Push(int2StrValue(3))
a.Push(int2StrValue(4))
checkSizeExp(t, &a, 4, 4)
checkSizeExp(t, a.Resize(10, 0), 10, 10)
checkSize(t, &a, 4, 4)
checkSize(t, a.Resize(10, 0), 10, 10)
for i := 4; i < a.Len(); i++ {
if a.At(i) != strzero {
t.Errorf("%T: expected a.At(%d) == %v; found %v!", a, i, strzero, a.At(i))
@ -63,7 +63,7 @@ func TestStrResize2Exp(t *testing.T) {
}
func checkStrZeroExp(t *testing.T, a *StringVector, i int) {
func checkStrZero(t *testing.T, a *StringVector, i int) {
for j := 0; j < i; j++ {
if a.At(j) == strzero {
t.Errorf("%T: 1 expected a.At(%d) == %d; found %v", a, j, j, a.At(j))
@ -83,45 +83,45 @@ func checkStrZeroExp(t *testing.T, a *StringVector, i int) {
}
func TestStrTrailingElementsExp(t *testing.T) {
func TestStrTrailingElements(t *testing.T) {
var a StringVector
for i := 0; i < 10; i++ {
a.Push(int2StrValue(i + 1))
}
checkStrZeroExp(t, &a, 10)
checkSizeExp(t, &a, 10, 16)
checkSizeExp(t, a.Resize(5, 0), 5, 16)
checkSizeExp(t, a.Resize(10, 0), 10, 16)
checkStrZeroExp(t, &a, 5)
checkStrZero(t, &a, 10)
checkSize(t, &a, 10, 16)
checkSize(t, a.Resize(5, 0), 5, 16)
checkSize(t, a.Resize(10, 0), 10, 16)
checkStrZero(t, &a, 5)
}
func TestStrAccessExp(t *testing.T) {
func TestStrAccess(t *testing.T) {
const n = 100
var a StringVector
a.Resize(n, 0)
for i := 0; i < n; i++ {
a.Set(i, int2StrValue(valExp(i)))
a.Set(i, int2StrValue(val(i)))
}
for i := 0; i < n; i++ {
if elem2StrValue(a.At(i)) != int2StrValue(valExp(i)) {
if elem2StrValue(a.At(i)) != int2StrValue(val(i)) {
t.Error(i)
}
}
var b StringVector
b.Resize(n, 0)
for i := 0; i < n; i++ {
b[i] = int2StrValue(valExp(i))
b[i] = int2StrValue(val(i))
}
for i := 0; i < n; i++ {
if elem2StrValue(b[i]) != int2StrValue(valExp(i)) {
if elem2StrValue(b[i]) != int2StrValue(val(i)) {
t.Error(i)
}
}
}
func TestStrInsertDeleteClearExp(t *testing.T) {
func TestStrInsertDeleteClear(t *testing.T) {
const n = 100
var a StringVector
@ -132,19 +132,19 @@ func TestStrInsertDeleteClearExp(t *testing.T) {
if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i)
}
a.Insert(0, int2StrValue(valExp(i)))
if elem2StrValue(a.Last()) != int2StrValue(valExp(0)) {
a.Insert(0, int2StrValue(val(i)))
if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
t.Error("T%: B", a)
}
}
for i := n - 1; i >= 0; i-- {
if elem2StrValue(a.Last()) != int2StrValue(valExp(0)) {
if elem2StrValue(a.Last()) != int2StrValue(val(0)) {
t.Error("T%: C", a)
}
if elem2StrValue(a.At(0)) != int2StrValue(valExp(i)) {
if elem2StrValue(a.At(0)) != int2StrValue(val(i)) {
t.Error("T%: D", a)
}
if elem2StrValue(a[0]) != int2StrValue(valExp(i)) {
if elem2StrValue(a[0]) != int2StrValue(val(i)) {
t.Error("T%: D2", a)
}
a.Delete(0)
@ -163,14 +163,14 @@ func TestStrInsertDeleteClearExp(t *testing.T) {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a))
}
for i := 0; i < n; i++ {
a.Push(int2StrValue(valExp(i)))
a.Push(int2StrValue(val(i)))
if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
}
if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1)
}
if elem2StrValue(a.Last()) != int2StrValue(valExp(i)) {
if elem2StrValue(a.Last()) != int2StrValue(val(i)) {
t.Error("T%: H", a)
}
}
@ -186,7 +186,7 @@ func TestStrInsertDeleteClearExp(t *testing.T) {
for j := 0; j < m; j++ {
a.Push(int2StrValue(j))
for i := 0; i < n; i++ {
x := valExp(i)
x := val(i)
a.Push(int2StrValue(x))
if elem2StrValue(a.Pop()) != int2StrValue(x) {
t.Error("T%: J", a)
@ -208,7 +208,7 @@ func TestStrInsertDeleteClearExp(t *testing.T) {
}
func verify_sliceStrExp(t *testing.T, x *StringVector, elt, i, j int) {
func verify_sliceStr(t *testing.T, x *StringVector, elt, i, j int) {
for k := i; k < j; k++ {
if elem2StrValue(x.At(k)) != int2StrValue(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2StrValue(x.At(k)), int2StrValue(elt))
@ -224,7 +224,7 @@ func verify_sliceStrExp(t *testing.T, x *StringVector, elt, i, j int) {
}
func verify_patternStrExp(t *testing.T, x *StringVector, a, b, c int) {
func verify_patternStr(t *testing.T, x *StringVector, a, b, c int) {
n := a + b + c
if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n)
@ -232,13 +232,13 @@ func verify_patternStrExp(t *testing.T, x *StringVector, a, b, c int) {
if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n)
}
verify_sliceStrExp(t, x, 0, 0, a)
verify_sliceStrExp(t, x, 1, a, a+b)
verify_sliceStrExp(t, x, 0, a+b, n)
verify_sliceStr(t, x, 0, 0, a)
verify_sliceStr(t, x, 1, a, a+b)
verify_sliceStr(t, x, 0, a+b, n)
}
func make_vectorStrExp(elt, len int) *StringVector {
func make_vectorStr(elt, len int) *StringVector {
x := new(StringVector).Resize(len, 0)
for i := 0; i < len; i++ {
x.Set(i, int2StrValue(elt))
@ -247,31 +247,31 @@ func make_vectorStrExp(elt, len int) *StringVector {
}
func TestStrInsertVectorExp(t *testing.T) {
func TestStrInsertVector(t *testing.T) {
// 1
a := make_vectorStrExp(0, 0)
b := make_vectorStrExp(1, 10)
a := make_vectorStr(0, 0)
b := make_vectorStr(1, 10)
a.InsertVector(0, b)
verify_patternStrExp(t, a, 0, 10, 0)
verify_patternStr(t, a, 0, 10, 0)
// 2
a = make_vectorStrExp(0, 10)
b = make_vectorStrExp(1, 0)
a = make_vectorStr(0, 10)
b = make_vectorStr(1, 0)
a.InsertVector(5, b)
verify_patternStrExp(t, a, 5, 0, 5)
verify_patternStr(t, a, 5, 0, 5)
// 3
a = make_vectorStrExp(0, 10)
b = make_vectorStrExp(1, 3)
a = make_vectorStr(0, 10)
b = make_vectorStr(1, 3)
a.InsertVector(3, b)
verify_patternStrExp(t, a, 3, 3, 7)
verify_patternStr(t, a, 3, 3, 7)
// 4
a = make_vectorStrExp(0, 10)
b = make_vectorStrExp(1, 1000)
a = make_vectorStr(0, 10)
b = make_vectorStr(1, 1000)
a.InsertVector(8, b)
verify_patternStrExp(t, a, 8, 1000, 2)
verify_patternStr(t, a, 8, 1000, 2)
}
func TestStrDoExp(t *testing.T) {
func TestStrDo(t *testing.T) {
const n = 25
const salt = 17
a := new(StringVector).Resize(n, 0)
@ -326,7 +326,7 @@ func TestStrDoExp(t *testing.T) {
}
func TestStrIterExp(t *testing.T) {
func TestStrIter(t *testing.T) {
const Len = 100
x := new(StringVector).Resize(Len, 0)
for i := 0; i < Len; i++ {

View File

@ -10,7 +10,7 @@ package vector
import "testing"
func TestZeroLenExp(t *testing.T) {
func TestZeroLen(t *testing.T) {
a := new(Vector)
if a.Len() != 0 {
t.Errorf("%T: B1) expected 0, got %d", a, a.Len())
@ -28,28 +28,28 @@ func TestZeroLenExp(t *testing.T) {
}
func TestResizeExp(t *testing.T) {
func TestResize(t *testing.T) {
var a Vector
checkSizeExp(t, &a, 0, 0)
checkSizeExp(t, a.Resize(0, 5), 0, 5)
checkSizeExp(t, a.Resize(1, 0), 1, 5)
checkSizeExp(t, a.Resize(10, 0), 10, 10)
checkSizeExp(t, a.Resize(5, 0), 5, 10)
checkSizeExp(t, a.Resize(3, 8), 3, 10)
checkSizeExp(t, a.Resize(0, 100), 0, 100)
checkSizeExp(t, a.Resize(11, 100), 11, 100)
checkSize(t, &a, 0, 0)
checkSize(t, a.Resize(0, 5), 0, 5)
checkSize(t, a.Resize(1, 0), 1, 5)
checkSize(t, a.Resize(10, 0), 10, 10)
checkSize(t, a.Resize(5, 0), 5, 10)
checkSize(t, a.Resize(3, 8), 3, 10)
checkSize(t, a.Resize(0, 100), 0, 100)
checkSize(t, a.Resize(11, 100), 11, 100)
}
func TestResize2Exp(t *testing.T) {
func TestResize2(t *testing.T) {
var a Vector
checkSizeExp(t, &a, 0, 0)
checkSize(t, &a, 0, 0)
a.Push(int2Value(1))
a.Push(int2Value(2))
a.Push(int2Value(3))
a.Push(int2Value(4))
checkSizeExp(t, &a, 4, 4)
checkSizeExp(t, a.Resize(10, 0), 10, 10)
checkSize(t, &a, 4, 4)
checkSize(t, a.Resize(10, 0), 10, 10)
for i := 4; i < a.Len(); i++ {
if a.At(i) != zero {
t.Errorf("%T: expected a.At(%d) == %v; found %v!", a, i, zero, a.At(i))
@ -63,7 +63,7 @@ func TestResize2Exp(t *testing.T) {
}
func checkZeroExp(t *testing.T, a *Vector, i int) {
func checkZero(t *testing.T, a *Vector, i int) {
for j := 0; j < i; j++ {
if a.At(j) == zero {
t.Errorf("%T: 1 expected a.At(%d) == %d; found %v", a, j, j, a.At(j))
@ -83,45 +83,45 @@ func checkZeroExp(t *testing.T, a *Vector, i int) {
}
func TestTrailingElementsExp(t *testing.T) {
func TestTrailingElements(t *testing.T) {
var a Vector
for i := 0; i < 10; i++ {
a.Push(int2Value(i + 1))
}
checkZeroExp(t, &a, 10)
checkSizeExp(t, &a, 10, 16)
checkSizeExp(t, a.Resize(5, 0), 5, 16)
checkSizeExp(t, a.Resize(10, 0), 10, 16)
checkZeroExp(t, &a, 5)
checkZero(t, &a, 10)
checkSize(t, &a, 10, 16)
checkSize(t, a.Resize(5, 0), 5, 16)
checkSize(t, a.Resize(10, 0), 10, 16)
checkZero(t, &a, 5)
}
func TestAccessExp(t *testing.T) {
func TestAccess(t *testing.T) {
const n = 100
var a Vector
a.Resize(n, 0)
for i := 0; i < n; i++ {
a.Set(i, int2Value(valExp(i)))
a.Set(i, int2Value(val(i)))
}
for i := 0; i < n; i++ {
if elem2Value(a.At(i)) != int2Value(valExp(i)) {
if elem2Value(a.At(i)) != int2Value(val(i)) {
t.Error(i)
}
}
var b Vector
b.Resize(n, 0)
for i := 0; i < n; i++ {
b[i] = int2Value(valExp(i))
b[i] = int2Value(val(i))
}
for i := 0; i < n; i++ {
if elem2Value(b[i]) != int2Value(valExp(i)) {
if elem2Value(b[i]) != int2Value(val(i)) {
t.Error(i)
}
}
}
func TestInsertDeleteClearExp(t *testing.T) {
func TestInsertDeleteClear(t *testing.T) {
const n = 100
var a Vector
@ -132,19 +132,19 @@ func TestInsertDeleteClearExp(t *testing.T) {
if len(a) != i {
t.Errorf("T%: A) wrong len() %d (expected %d)", a, len(a), i)
}
a.Insert(0, int2Value(valExp(i)))
if elem2Value(a.Last()) != int2Value(valExp(0)) {
a.Insert(0, int2Value(val(i)))
if elem2Value(a.Last()) != int2Value(val(0)) {
t.Error("T%: B", a)
}
}
for i := n - 1; i >= 0; i-- {
if elem2Value(a.Last()) != int2Value(valExp(0)) {
if elem2Value(a.Last()) != int2Value(val(0)) {
t.Error("T%: C", a)
}
if elem2Value(a.At(0)) != int2Value(valExp(i)) {
if elem2Value(a.At(0)) != int2Value(val(i)) {
t.Error("T%: D", a)
}
if elem2Value(a[0]) != int2Value(valExp(i)) {
if elem2Value(a[0]) != int2Value(val(i)) {
t.Error("T%: D2", a)
}
a.Delete(0)
@ -163,14 +163,14 @@ func TestInsertDeleteClearExp(t *testing.T) {
t.Errorf("T%: F) wrong len() %d (expected 0)", a, len(a))
}
for i := 0; i < n; i++ {
a.Push(int2Value(valExp(i)))
a.Push(int2Value(val(i)))
if a.Len() != i+1 {
t.Errorf("T%: G) wrong Len() %d (expected %d)", a, a.Len(), i+1)
}
if len(a) != i+1 {
t.Errorf("T%: G) wrong len() %d (expected %d)", a, len(a), i+1)
}
if elem2Value(a.Last()) != int2Value(valExp(i)) {
if elem2Value(a.Last()) != int2Value(val(i)) {
t.Error("T%: H", a)
}
}
@ -186,7 +186,7 @@ func TestInsertDeleteClearExp(t *testing.T) {
for j := 0; j < m; j++ {
a.Push(int2Value(j))
for i := 0; i < n; i++ {
x := valExp(i)
x := val(i)
a.Push(int2Value(x))
if elem2Value(a.Pop()) != int2Value(x) {
t.Error("T%: J", a)
@ -208,7 +208,7 @@ func TestInsertDeleteClearExp(t *testing.T) {
}
func verify_sliceExp(t *testing.T, x *Vector, elt, i, j int) {
func verify_slice(t *testing.T, x *Vector, elt, i, j int) {
for k := i; k < j; k++ {
if elem2Value(x.At(k)) != int2Value(elt) {
t.Errorf("T%: M) wrong [%d] element %v (expected %v)", x, k, elem2Value(x.At(k)), int2Value(elt))
@ -224,7 +224,7 @@ func verify_sliceExp(t *testing.T, x *Vector, elt, i, j int) {
}
func verify_patternExp(t *testing.T, x *Vector, a, b, c int) {
func verify_pattern(t *testing.T, x *Vector, a, b, c int) {
n := a + b + c
if x.Len() != n {
t.Errorf("T%: O) wrong Len() %d (expected %d)", x, x.Len(), n)
@ -232,13 +232,13 @@ func verify_patternExp(t *testing.T, x *Vector, a, b, c int) {
if len(*x) != n {
t.Errorf("T%: O) wrong len() %d (expected %d)", x, len(*x), n)
}
verify_sliceExp(t, x, 0, 0, a)
verify_sliceExp(t, x, 1, a, a+b)
verify_sliceExp(t, x, 0, a+b, n)
verify_slice(t, x, 0, 0, a)
verify_slice(t, x, 1, a, a+b)
verify_slice(t, x, 0, a+b, n)
}
func make_vectorExp(elt, len int) *Vector {
func make_vector(elt, len int) *Vector {
x := new(Vector).Resize(len, 0)
for i := 0; i < len; i++ {
x.Set(i, int2Value(elt))
@ -247,31 +247,31 @@ func make_vectorExp(elt, len int) *Vector {
}
func TestInsertVectorExp(t *testing.T) {
func TestInsertVector(t *testing.T) {
// 1
a := make_vectorExp(0, 0)
b := make_vectorExp(1, 10)
a := make_vector(0, 0)
b := make_vector(1, 10)
a.InsertVector(0, b)
verify_patternExp(t, a, 0, 10, 0)
verify_pattern(t, a, 0, 10, 0)
// 2
a = make_vectorExp(0, 10)
b = make_vectorExp(1, 0)
a = make_vector(0, 10)
b = make_vector(1, 0)
a.InsertVector(5, b)
verify_patternExp(t, a, 5, 0, 5)
verify_pattern(t, a, 5, 0, 5)
// 3
a = make_vectorExp(0, 10)
b = make_vectorExp(1, 3)
a = make_vector(0, 10)
b = make_vector(1, 3)
a.InsertVector(3, b)
verify_patternExp(t, a, 3, 3, 7)
verify_pattern(t, a, 3, 3, 7)
// 4
a = make_vectorExp(0, 10)
b = make_vectorExp(1, 1000)
a = make_vector(0, 10)
b = make_vector(1, 1000)
a.InsertVector(8, b)
verify_patternExp(t, a, 8, 1000, 2)
verify_pattern(t, a, 8, 1000, 2)
}
func TestDoExp(t *testing.T) {
func TestDo(t *testing.T) {
const n = 25
const salt = 17
a := new(Vector).Resize(n, 0)
@ -326,7 +326,7 @@ func TestDoExp(t *testing.T) {
}
func TestIterExp(t *testing.T) {
func TestIter(t *testing.T) {
const Len = 100
x := new(Vector).Resize(Len, 0)
for i := 0; i < Len; i++ {