1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package pds
import (
g "gobang"
)
func MainTest() {
g.Testing("API usage", func() {
b1 := NewVectorBuilder[string]()
b1.Append("foo")
b1.Append("bar")
b1.Append("baz")
l1 := b1.Vector()
g.TAssertEqual(l1.Get(0), "foo")
g.TAssertEqual(l1.Get(1), "bar")
g.TAssertEqual(l1.Get(2), "baz")
b2 := NewVectorBuilder[string]()
b2.Prepend("foo")
b2.Prepend("bar")
b2.Prepend("baz")
l2 := b2.Vector()
g.TAssertEqual(l2.Get(0), "baz")
g.TAssertEqual(l2.Get(1), "bar")
g.TAssertEqual(l2.Get(2), "foo")
b3 := NewVectorBuilder[string]()
b3.Append("foo")
b3.Append("bar")
b3.Set(1, "___")
l3 := b3.Vector()
g.TAssertEqual(l3.Get(0), "foo")
g.TAssertEqual(l3.Get(1), "___")
b4 := NewVectorBuilder[string]()
b4.Append("foo")
b4.Append("bar")
b4.Append("baz")
b4.Slice(1, 3)
l4 := b4.Vector()
g.TAssertEqual(l4.Len(), 2)
g.TAssertEqual(l4.Get(0), "bar")
g.TAssertEqual(l4.Get(1), "baz")
})
}
|