aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
l---------tests/benchmarks/vector-append/main.go (renamed from tests/benchmarks/list-append/main.go)0
-rw-r--r--tests/benchmarks/vector-append/pds.go (renamed from tests/benchmarks/list-append/pds.go)2
l---------tests/benchmarks/vector-builder-append/main.go (renamed from tests/benchmarks/list-builder-append/main.go)0
-rw-r--r--tests/benchmarks/vector-builder-append/pds.go (renamed from tests/benchmarks/list-builder-append/pds.go)2
l---------tests/benchmarks/vector-builder-prepend/main.go (renamed from tests/benchmarks/list-builder-prepend/main.go)0
-rw-r--r--tests/benchmarks/vector-builder-prepend/pds.go (renamed from tests/benchmarks/list-builder-prepend/pds.go)2
l---------tests/benchmarks/vector-builder-set/main.go (renamed from tests/benchmarks/list-builder-set/main.go)0
-rw-r--r--tests/benchmarks/vector-builder-set/pds.go (renamed from tests/benchmarks/list-builder-set/pds.go)2
l---------tests/benchmarks/vector-iterator-backward/main.go (renamed from tests/benchmarks/list-iterator-backward/main.go)0
-rw-r--r--tests/benchmarks/vector-iterator-backward/pds.go (renamed from tests/benchmarks/list-iterator-backward/pds.go)2
l---------tests/benchmarks/vector-iterator-forward/main.go (renamed from tests/benchmarks/list-iterator-forward/main.go)0
-rw-r--r--tests/benchmarks/vector-iterator-forward/pds.go (renamed from tests/benchmarks/list-iterator-forward/pds.go)2
l---------tests/benchmarks/vector-prepend/main.go (renamed from tests/benchmarks/list-prepend/main.go)0
-rw-r--r--tests/benchmarks/vector-prepend/pds.go (renamed from tests/benchmarks/list-prepend/pds.go)2
l---------tests/benchmarks/vector-set/main.go (renamed from tests/benchmarks/list-set/main.go)0
-rw-r--r--tests/benchmarks/vector-set/pds.go (renamed from tests/benchmarks/list-set/pds.go)2
l---------tests/functional/vector-api/main.go (renamed from tests/functional/list-api/main.go)0
-rw-r--r--tests/functional/vector-api/pds.go (renamed from tests/functional/list-api/pds.go)8
l---------tests/functional/vector-builder-api/main.go (renamed from tests/functional/list-builder-api/main.go)0
-rw-r--r--tests/functional/vector-builder-api/pds.go (renamed from tests/functional/list-builder-api/pds.go)16
-rw-r--r--tests/pds.go172
21 files changed, 106 insertions, 106 deletions
diff --git a/tests/benchmarks/list-append/main.go b/tests/benchmarks/vector-append/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-append/main.go
+++ b/tests/benchmarks/vector-append/main.go
diff --git a/tests/benchmarks/list-append/pds.go b/tests/benchmarks/vector-append/pds.go
index a9b7690..58368b3 100644
--- a/tests/benchmarks/list-append/pds.go
+++ b/tests/benchmarks/vector-append/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- l := NewList[int]()
+ l := NewVector[int]()
for i := 0; i < n; i++ {
l = l.Append(i)
}
diff --git a/tests/benchmarks/list-builder-append/main.go b/tests/benchmarks/vector-builder-append/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-builder-append/main.go
+++ b/tests/benchmarks/vector-builder-append/main.go
diff --git a/tests/benchmarks/list-builder-append/pds.go b/tests/benchmarks/vector-builder-append/pds.go
index 3357ee6..ab5cdec 100644
--- a/tests/benchmarks/list-builder-append/pds.go
+++ b/tests/benchmarks/vector-builder-append/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- builder := NewListBuilder[int]()
+ builder := NewVectorBuilder[int]()
for i := 0; i < n; i++ {
builder.Append(i)
}
diff --git a/tests/benchmarks/list-builder-prepend/main.go b/tests/benchmarks/vector-builder-prepend/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-builder-prepend/main.go
+++ b/tests/benchmarks/vector-builder-prepend/main.go
diff --git a/tests/benchmarks/list-builder-prepend/pds.go b/tests/benchmarks/vector-builder-prepend/pds.go
index 572b6b6..9d1d669 100644
--- a/tests/benchmarks/list-builder-prepend/pds.go
+++ b/tests/benchmarks/vector-builder-prepend/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- builder := NewListBuilder[int]()
+ builder := NewVectorBuilder[int]()
for i := 0; i < n; i++ {
builder.Prepend(i)
}
diff --git a/tests/benchmarks/list-builder-set/main.go b/tests/benchmarks/vector-builder-set/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-builder-set/main.go
+++ b/tests/benchmarks/vector-builder-set/main.go
diff --git a/tests/benchmarks/list-builder-set/pds.go b/tests/benchmarks/vector-builder-set/pds.go
index 4080e22..c4d5b2b 100644
--- a/tests/benchmarks/list-builder-set/pds.go
+++ b/tests/benchmarks/vector-builder-set/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- builder := NewListBuilder[int]()
+ builder := NewVectorBuilder[int]()
for i := 0; i < n; i++ {
builder.Append(i)
}
diff --git a/tests/benchmarks/list-iterator-backward/main.go b/tests/benchmarks/vector-iterator-backward/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-iterator-backward/main.go
+++ b/tests/benchmarks/vector-iterator-backward/main.go
diff --git a/tests/benchmarks/list-iterator-backward/pds.go b/tests/benchmarks/vector-iterator-backward/pds.go
index 6ca51e4..a03e138 100644
--- a/tests/benchmarks/list-iterator-backward/pds.go
+++ b/tests/benchmarks/vector-iterator-backward/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- l := NewList[int]()
+ l := NewVector[int]()
for i := 0; i < n; i++ {
l = l.Append(i)
}
diff --git a/tests/benchmarks/list-iterator-forward/main.go b/tests/benchmarks/vector-iterator-forward/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-iterator-forward/main.go
+++ b/tests/benchmarks/vector-iterator-forward/main.go
diff --git a/tests/benchmarks/list-iterator-forward/pds.go b/tests/benchmarks/vector-iterator-forward/pds.go
index 6831dad..298fd4e 100644
--- a/tests/benchmarks/list-iterator-forward/pds.go
+++ b/tests/benchmarks/vector-iterator-forward/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- l := NewList[int]()
+ l := NewVector[int]()
for i := 0; i < n; i++ {
l = l.Append(i)
}
diff --git a/tests/benchmarks/list-prepend/main.go b/tests/benchmarks/vector-prepend/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-prepend/main.go
+++ b/tests/benchmarks/vector-prepend/main.go
diff --git a/tests/benchmarks/list-prepend/pds.go b/tests/benchmarks/vector-prepend/pds.go
index 918ff72..4f82cea 100644
--- a/tests/benchmarks/list-prepend/pds.go
+++ b/tests/benchmarks/vector-prepend/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- l := NewList[int]()
+ l := NewVector[int]()
for i := 0; i < n; i++ {
l = l.Prepend(i)
}
diff --git a/tests/benchmarks/list-set/main.go b/tests/benchmarks/vector-set/main.go
index f67563d..f67563d 120000
--- a/tests/benchmarks/list-set/main.go
+++ b/tests/benchmarks/vector-set/main.go
diff --git a/tests/benchmarks/list-set/pds.go b/tests/benchmarks/vector-set/pds.go
index e2d3709..ce0ee55 100644
--- a/tests/benchmarks/list-set/pds.go
+++ b/tests/benchmarks/vector-set/pds.go
@@ -16,7 +16,7 @@ func MainTest() {
flag.Parse()
n := *nFlag
- l := NewList[int]()
+ l := NewVector[int]()
for i := 0; i < n; i++ {
l = l.Append(i)
}
diff --git a/tests/functional/list-api/main.go b/tests/functional/vector-api/main.go
index f67563d..f67563d 120000
--- a/tests/functional/list-api/main.go
+++ b/tests/functional/vector-api/main.go
diff --git a/tests/functional/list-api/pds.go b/tests/functional/vector-api/pds.go
index c4290c8..aa37949 100644
--- a/tests/functional/list-api/pds.go
+++ b/tests/functional/vector-api/pds.go
@@ -7,8 +7,8 @@ import (
func MainTest() {
- g.Testing("NewList() - API usage", func() {
- l := NewList[string]().Append("foo").Append("bar").Append("baz")
+ g.Testing("NewVector() - API usage", func() {
+ l := NewVector[string]().Append("foo").Append("bar").Append("baz")
g.TAssertEqual(l.Get(0), "foo")
g.TAssertEqual(l.Get(1), "bar")
g.TAssertEqual(l.Get(2), "baz")
@@ -27,8 +27,8 @@ func MainTest() {
g.TAssertEqual(l.Len(), 2)
})
- g.Testing("NewList().Iterator() - API usage", func() {
- l := NewList[string]()
+ g.Testing("NewVector().Iterator() - API usage", func() {
+ l := NewVector[string]()
l = l.Append("foo")
l = l.Append("bar")
l = l.Append("baz")
diff --git a/tests/functional/list-builder-api/main.go b/tests/functional/vector-builder-api/main.go
index f67563d..f67563d 120000
--- a/tests/functional/list-builder-api/main.go
+++ b/tests/functional/vector-builder-api/main.go
diff --git a/tests/functional/list-builder-api/pds.go b/tests/functional/vector-builder-api/pds.go
index c7b632c..6dd8c2f 100644
--- a/tests/functional/list-builder-api/pds.go
+++ b/tests/functional/vector-builder-api/pds.go
@@ -8,44 +8,44 @@ import (
func MainTest() {
g.Testing("API usage", func() {
- b1 := NewListBuilder[string]()
+ b1 := NewVectorBuilder[string]()
b1.Append("foo")
b1.Append("bar")
b1.Append("baz")
- l1 := b1.List()
+ l1 := b1.Vector()
g.TAssertEqual(l1.Get(0), "foo")
g.TAssertEqual(l1.Get(1), "bar")
g.TAssertEqual(l1.Get(2), "baz")
- b2 := NewListBuilder[string]()
+ b2 := NewVectorBuilder[string]()
b2.Prepend("foo")
b2.Prepend("bar")
b2.Prepend("baz")
- l2 := b2.List()
+ l2 := b2.Vector()
g.TAssertEqual(l2.Get(0), "baz")
g.TAssertEqual(l2.Get(1), "bar")
g.TAssertEqual(l2.Get(2), "foo")
- b3 := NewListBuilder[string]()
+ b3 := NewVectorBuilder[string]()
b3.Append("foo")
b3.Append("bar")
b3.Set(1, "___")
- l3 := b3.List()
+ l3 := b3.Vector()
g.TAssertEqual(l3.Get(0), "foo")
g.TAssertEqual(l3.Get(1), "___")
- b4 := NewListBuilder[string]()
+ b4 := NewVectorBuilder[string]()
b4.Append("foo")
b4.Append("bar")
b4.Append("baz")
b4.Slice(1, 3)
- l4 := b4.List()
+ l4 := b4.Vector()
g.TAssertEqual(l4.Len(), 2)
g.TAssertEqual(l4.Get(0), "bar")
g.TAssertEqual(l4.Get(1), "baz")
diff --git a/tests/pds.go b/tests/pds.go
index 049edae..33ef400 100644
--- a/tests/pds.go
+++ b/tests/pds.go
@@ -15,50 +15,50 @@ import (
-func test_NewList() {
- g.TestStart("NewList[]()")
+func test_NewVector() {
+ g.TestStart("NewVector[]()")
- g.Testing("a brand new list starts empty", func() {
- g.TAssertEqual(NewList[int]().Len(), 0)
+ g.Testing("a brand new vector starts empty", func() {
+ g.TAssertEqual(NewVector[int]().Len(), 0)
})
}
-func TestList(t *testing.T) {
+func TestVector(t *testing.T) {
t.Run("Shallow", func(t *testing.T) {
- list := NewList[string]()
- list = list.Append("foo")
- if v := list.Get(0); v != "foo" {
+ vector := NewVector[string]()
+ vector = vector.Append("foo")
+ if v := vector.Get(0); v != "foo" {
t.Fatalf("unexpected value: %v", v)
}
- other := list.Append("bar")
+ other := vector.Append("bar")
if v := other.Get(0); v != "foo" {
t.Fatalf("unexpected value: %v", v)
} else if v := other.Get(1); v != "bar" {
t.Fatalf("unexpected value: %v", v)
}
- if v := list.Len(); v != 1 {
+ if v := vector.Len(); v != 1 {
t.Fatalf("unexpected value: %v", v)
}
})
t.Run("Deep", func(t *testing.T) {
- list := NewList[int]()
+ vector := NewVector[int]()
var array []int
const n = 1000 // FIXME: 100000 was too slow
for i := 0; i < n; i++ {
- list = list.Append(i)
+ vector = vector.Append(i)
array = append(array, i)
}
- if got, exp := len(array), list.Len(); got != exp {
- t.Fatalf("List.Len()=%d, exp %d", got, exp)
+ if got, exp := len(array), vector.Len(); got != exp {
+ t.Fatalf("Vector.Len()=%d, exp %d", got, exp)
}
for j := range array {
- if got, exp := list.Get(j), array[j]; got != exp {
+ if got, exp := vector.Get(j), array[j]; got != exp {
t.Fatalf(
- "%d. List.Get(%d)=%d, exp %d",
+ "%d. Vector.Get(%d)=%d, exp %d",
len(array),
j,
got,
@@ -69,18 +69,18 @@ func TestList(t *testing.T) {
})
t.Run("Set", func(t *testing.T) {
- list := NewList[string]()
- list = list.Append("foo")
- list = list.Append("bar")
+ vector := NewVector[string]()
+ vector = vector.Append("foo")
+ vector = vector.Append("bar")
- if v := list.Get(0); v != "foo" {
+ if v := vector.Get(0); v != "foo" {
t.Fatalf("unexpected value: %v", v)
}
- list = list.Set(0, "baz")
- if v := list.Get(0); v != "baz" {
+ vector = vector.Set(0, "baz")
+ if v := vector.Get(0); v != "baz" {
t.Fatalf("unexpected value: %v", v)
- } else if v := list.Get(1); v != "bar" {
+ } else if v := vector.Get(1); v != "bar" {
t.Fatalf("unexpected value: %v", v)
}
})
@@ -89,11 +89,11 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l.Get(-1)
}()
- if r != `immutable.List.Get: index -1 out of bounds` {
+ if r != `immutable.Vector.Get: index -1 out of bounds` {
t.Fatalf("unexpected panic: %q", r)
}
})
@@ -102,11 +102,11 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l.Get(1)
}()
- if r != `immutable.List.Get: index 1 out of bounds` {
+ if r != `immutable.Vector.Get: index 1 out of bounds` {
t.Fatalf("unexpected panic: %q", r)
}
})
@@ -115,11 +115,11 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l.Set(1, "bar")
}()
- if r != `immutable.List.Set: index 1 out of bounds` {
+ if r != `immutable.Vector.Set: index 1 out of bounds` {
t.Fatalf("unexpected panic: %q", r)
}
})
@@ -128,11 +128,11 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l.Slice(2, 3)
}()
- if r != `immutable.List.Slice: start index 2 out of bounds` {
+ if r != `immutable.Vector.Slice: start index 2 out of bounds` {
t.Fatalf("unexpected panic: %q", r)
}
})
@@ -141,11 +141,11 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l.Slice(1, 3)
}()
- if r != `immutable.List.Slice: end index 3 out of bounds` {
+ if r != `immutable.Vector.Slice: end index 3 out of bounds` {
t.Fatalf("unexpected panic: %q", r)
}
})
@@ -154,25 +154,25 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l = l.Append("bar")
l.Slice(2, 1)
}()
- if r != `immutable.List.Slice: invalid slice index: [2:1]` {
+ if r != `immutable.Vector.Slice: invalid slice index: [2:1]` {
t.Fatalf("unexpected panic: %q", r)
}
})
t.Run("SliceBeginning", func(t *testing.T) {
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l = l.Append("bar")
l = l.Slice(1, 2)
if got, exp := l.Len(), 1; got != exp {
- t.Fatalf("List.Len()=%d, exp %d", got, exp)
+ t.Fatalf("Vector.Len()=%d, exp %d", got, exp)
} else if got, exp := l.Get(0), "bar"; got != exp {
- t.Fatalf("List.Get(0)=%v, exp %v", got, exp)
+ t.Fatalf("Vector.Get(0)=%v, exp %v", got, exp)
}
})
@@ -180,35 +180,35 @@ func TestList(t *testing.T) {
var r string
func() {
defer func() { r = recover().(string) }()
- l := NewList[string]()
+ l := NewVector[string]()
l = l.Append("foo")
l.Iterator().Seek(-1)
}()
- if r != `immutable.ListIterator.Seek: index -1 out of bounds` {
+ if r != `immutable.VectorIterator.Seek: index -1 out of bounds` {
t.Fatalf("unexpected panic: %q", r)
}
})
t.Run("TestSliceFreesReferences", func(t *testing.T) {
- // Test that the leaf node in a sliced list contains zero'ed
+ // Test that the leaf node in a sliced vector contains zero'ed
// entries at the correct positions. To do this we directly
- // access the internal tree structure of the list.
- l := NewList[*int]()
+ // access the internal tree structure of the vector.
+ l := NewVector[*int]()
var ints [5]int
for i := 0; i < 5; i++ {
l = l.Append(&ints[i])
}
sl := l.Slice(2, 4)
- var findLeaf func(listNode[*int]) *listLeafNode[*int]
- findLeaf = func(n listNode[*int]) *listLeafNode[*int] {
+ var findLeaf func(vectorNode[*int]) *vectorLeafNode[*int]
+ findLeaf = func(n vectorNode[*int]) *vectorLeafNode[*int] {
switch n := n.(type) {
- case *listBranchNode[*int]:
+ case *vectorBranchNode[*int]:
if n.children[0] == nil {
t.Fatal("Failed to find leaf node due to nil child")
}
return findLeaf(n.children[0])
- case *listLeafNode[*int]:
+ case *vectorLeafNode[*int]:
return n
default:
panic("Unexpected case")
@@ -220,7 +220,7 @@ func TestList(t *testing.T) {
t.Errorf("Expected occupied to be 1100, was %032b", leaf.occupied)
}
- for i := 0; i < listNodeSize; i++ {
+ for i := 0; i < vectorNodeSize; i++ {
if 2 <= i && i < 4 {
if leaf.children[i] != &ints[i] {
t.Errorf("Position %v does not contain the right pointer?", i)
@@ -232,12 +232,12 @@ func TestList(t *testing.T) {
})
t.Run("AppendImmutable", func(t *testing.T) {
- outer_l := NewList[int]()
+ outer_l := NewVector[int]()
for N := 0; N < 1_000; N++ {
l1 := outer_l.Append(0)
outer_l.Append(1)
if actual := l1.Get(N); actual != 0 {
- t.Fatalf("Append mutates list with %d elements. Got %d instead of 0", N, actual)
+ t.Fatalf("Append mutates vector with %d elements. Got %d instead of 0", N, actual)
}
outer_l = outer_l.Append(0)
@@ -246,7 +246,7 @@ func TestList(t *testing.T) {
RunRandom(t, "Random", func(t *testing.T, rand *rand.Rand) {
const n = 100 // FIXME: 100000 was too slow
- l := newTList()
+ l := newTVector()
for i := 0; i < n; i++ {
rnd := rand.Intn(70)
switch {
@@ -269,29 +269,29 @@ func TestList(t *testing.T) {
})
}
-// TList represents a list that operates on a standard Go slice & immutable
-// list.
-type tList struct {
- im, prev *List[int]
- builder *ListBuilder[int]
+// TVector represents a vector that operates on a standard Go slice & immutable
+// vector.
+type tVector struct {
+ im, prev *Vector[int]
+ builder *VectorBuilder[int]
std []int
}
-// newTList returns a new instance of tList.
-func newTList() *tList {
- return &tList{
- im: NewList[int](),
- builder: NewListBuilder[int](),
+// newTVector returns a new instance of tVector.
+func newTVector() *tVector {
+ return &tVector{
+ im: NewVector[int](),
+ builder: NewVectorBuilder[int](),
}
}
-// Len returns the size of the list.
-func (l *tList) Len() int {
+// Len returns the size of the vector.
+func (l *tVector) Len() int {
return len(l.std)
}
// ChooseIndex returns a randomly chosen, valid index from the standard slice.
-func (l *tList) ChooseIndex(rand *rand.Rand) int {
+func (l *tVector) ChooseIndex(rand *rand.Rand) int {
if len(l.std) == 0 {
return -1
}
@@ -299,7 +299,7 @@ func (l *tList) ChooseIndex(rand *rand.Rand) int {
}
// ChooseSliceIndices returns randomly chosen, valid indices for slicing.
-func (l *tList) ChooseSliceIndices(rand *rand.Rand) (start, end int) {
+func (l *tVector) ChooseSliceIndices(rand *rand.Rand) (start, end int) {
if len(l.std) == 0 {
return 0, 0
}
@@ -308,40 +308,40 @@ func (l *tList) ChooseSliceIndices(rand *rand.Rand) (start, end int) {
return start, end
}
-// Append adds v to the end of slice and List.
-func (l *tList) Append(v int) {
+// Append adds v to the end of slice and Vector.
+func (l *tVector) Append(v int) {
l.prev = l.im
l.im = l.im.Append(v)
l.builder.Append(v)
l.std = append(l.std, v)
}
-// Prepend adds v to the beginning of the slice and List.
-func (l *tList) Prepend(v int) {
+// Prepend adds v to the beginning of the slice and Vector.
+func (l *tVector) Prepend(v int) {
l.prev = l.im
l.im = l.im.Prepend(v)
l.builder.Prepend(v)
l.std = append([]int{v}, l.std...)
}
-// Set updates the value at index i to v in the slice and List.
-func (l *tList) Set(i, v int) {
+// Set updates the value at index i to v in the slice and Vector.
+func (l *tVector) Set(i, v int) {
l.prev = l.im
l.im = l.im.Set(i, v)
l.builder.Set(i, v)
l.std[i] = v
}
-// Slice contracts the slice and List to the range of start/end indices.
-func (l *tList) Slice(start, end int) {
+// Slice contracts the slice and Vector to the range of start/end indices.
+func (l *tVector) Slice(start, end int) {
l.prev = l.im
l.im = l.im.Slice(start, end)
l.builder.Slice(start, end)
l.std = l.std[start:end]
}
-// Validate returns an error if the slice and List are different.
-func (l *tList) Validate() error {
+// Validate returns an error if the slice and Vector are different.
+func (l *tVector) Validate() error {
if got, exp := l.im.Len(), len(l.std); got != exp {
return fmt.Errorf("Len()=%v, expected %d", got, exp)
} else if got, exp := l.builder.Len(), len(l.std); got != exp {
@@ -352,7 +352,7 @@ func (l *tList) Validate() error {
if got, exp := l.im.Get(i), l.std[i]; got != exp {
return fmt.Errorf("Get(%d)=%v, expected %v", i, got, exp)
} else if got, exp := l.builder.Get(i), l.std[i]; got != exp {
- return fmt.Errorf("Builder.List/Get(%d)=%v, expected %v", i, got, exp)
+ return fmt.Errorf("Builder.Vector/Get(%d)=%v, expected %v", i, got, exp)
}
}
@@ -370,37 +370,37 @@ func (l *tList) Validate() error {
return nil
}
-func (l *tList) validateForwardIterator(typ string, itr *ListIterator[int]) error {
+func (l *tVector) validateForwardIterator(typ string, itr *VectorIterator[int]) error {
for i := range l.std {
if j, v := itr.Next(); i != j || l.std[i] != v {
- return fmt.Errorf("ListIterator.Next()=<%v,%v>, expected <%v,%v> [%s]", j, v, i, l.std[i], typ)
+ return fmt.Errorf("VectorIterator.Next()=<%v,%v>, expected <%v,%v> [%s]", j, v, i, l.std[i], typ)
}
done := i == len(l.std)-1
if v := itr.Done(); v != done {
- return fmt.Errorf("ListIterator.Done()=%v, expected %v [%s]", v, done, typ)
+ return fmt.Errorf("VectorIterator.Done()=%v, expected %v [%s]", v, done, typ)
}
}
if i, v := itr.Next(); i != -1 || v != 0 {
- return fmt.Errorf("ListIterator.Next()=<%v,%v>, expected DONE [%s]", i, v, typ)
+ return fmt.Errorf("VectorIterator.Next()=<%v,%v>, expected DONE [%s]", i, v, typ)
}
return nil
}
-func (l *tList) validateBackwardIterator(typ string, itr *ListIterator[int]) error {
+func (l *tVector) validateBackwardIterator(typ string, itr *VectorIterator[int]) error {
itr.Last()
for i := len(l.std) - 1; i >= 0; i-- {
if j, v := itr.Prev(); i != j || l.std[i] != v {
- return fmt.Errorf("ListIterator.Prev()=<%v,%v>, expected <%v,%v> [%s]", j, v, i, l.std[i], typ)
+ return fmt.Errorf("VectorIterator.Prev()=<%v,%v>, expected <%v,%v> [%s]", j, v, i, l.std[i], typ)
}
done := i == 0
if v := itr.Done(); v != done {
- return fmt.Errorf("ListIterator.Done()=%v, expected %v [%s]", v, done, typ)
+ return fmt.Errorf("VectorIterator.Done()=%v, expected %v [%s]", v, done, typ)
}
}
if i, v := itr.Prev(); i != -1 || v != 0 {
- return fmt.Errorf("ListIterator.Prev()=<%v,%v>, expected DONE [%s]", i, v, typ)
+ return fmt.Errorf("VectorIterator.Prev()=<%v,%v>, expected DONE [%s]", i, v, typ)
}
return nil
}
@@ -2030,10 +2030,10 @@ func TestSortedSetBuilder(t *testing.T) {
func MainTest() {
- test_NewList()
+ test_NewVector()
tests := []testing.InternalTest{
- { "TestList", TestList },
+ { "TestVector", TestVector },
{ "TestInternal_mapNode_Overwrite", TestInternal_mapNode_Overwrite },
{ "TestInternal_mapArrayNode", TestInternal_mapArrayNode },
{ "TestInternal_mapValueNode", TestInternal_mapValueNode },