<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/walk/walk_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'walk/walk_test.go')
-rw-r--r--walk/walk_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/walk/walk_test.go b/walk/walk_test.go
new file mode 100644
index 0000000..c05da02
--- /dev/null
+++ b/walk/walk_test.go
@@ -0,0 +1,45 @@
+package walk
+
+import (
+ "testing"
+ "log"
+)
+
+func TestValueIter(t *testing.T) {
+ values := ValueList{
+ NumberScalar(1),
+ NumberScalar(2),
+ NumberScalar(3),
+ }
+
+ valuesCopy := ValueList{}
+
+ iter := NewValueIter(values)
+
+ for {
+ edible := iter.Next()
+ if edible == nil {
+ break
+ }
+
+ log.Println(edible)
+
+ value, isValue := edible.(Value)
+
+ if !isValue {
+ t.Fatalf("Iterator produced a non-value")
+ }
+
+ valuesCopy = append(valuesCopy, value)
+ }
+
+ if len(values) != len(valuesCopy) {
+ t.Fatalf("iter gave the wrong number of values")
+ }
+
+ for i, value := range values {
+ if value != valuesCopy[i] {
+ t.Fatalf("iter produced an incorrect value")
+ }
+ }
+}