aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/list-builder-api/pds.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/list-builder-api/pds.go')
-rw-r--r--tests/functional/list-builder-api/pds.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/functional/list-builder-api/pds.go b/tests/functional/list-builder-api/pds.go
new file mode 100644
index 0000000..c7b632c
--- /dev/null
+++ b/tests/functional/list-builder-api/pds.go
@@ -0,0 +1,53 @@
+package pds
+
+import (
+ g "gobang"
+)
+
+
+
+func MainTest() {
+ g.Testing("API usage", func() {
+ b1 := NewListBuilder[string]()
+ b1.Append("foo")
+ b1.Append("bar")
+ b1.Append("baz")
+
+ l1 := b1.List()
+ g.TAssertEqual(l1.Get(0), "foo")
+ g.TAssertEqual(l1.Get(1), "bar")
+ g.TAssertEqual(l1.Get(2), "baz")
+
+
+ b2 := NewListBuilder[string]()
+ b2.Prepend("foo")
+ b2.Prepend("bar")
+ b2.Prepend("baz")
+
+ l2 := b2.List()
+ g.TAssertEqual(l2.Get(0), "baz")
+ g.TAssertEqual(l2.Get(1), "bar")
+ g.TAssertEqual(l2.Get(2), "foo")
+
+
+ b3 := NewListBuilder[string]()
+ b3.Append("foo")
+ b3.Append("bar")
+ b3.Set(1, "___")
+ l3 := b3.List()
+ g.TAssertEqual(l3.Get(0), "foo")
+ g.TAssertEqual(l3.Get(1), "___")
+
+
+ b4 := NewListBuilder[string]()
+ b4.Append("foo")
+ b4.Append("bar")
+ b4.Append("baz")
+ b4.Slice(1, 3)
+
+ l4 := b4.List()
+ g.TAssertEqual(l4.Len(), 2)
+ g.TAssertEqual(l4.Get(0), "bar")
+ g.TAssertEqual(l4.Get(1), "baz")
+ })
+}