summaryrefslogtreecommitdiff
path: root/src/lib/container/iterable_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/container/iterable_test.go')
-rw-r--r--src/lib/container/iterable_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/container/iterable_test.go b/src/lib/container/iterable_test.go
index f266a955b..ceb1de6e4 100644
--- a/src/lib/container/iterable_test.go
+++ b/src/lib/container/iterable_test.go
@@ -42,6 +42,9 @@ func doubler(n interface {}) interface {} {
func addOne(n interface {}) interface {} {
return n.(int) + 1
}
+func adder(acc interface {}, n interface {}) interface {} {
+ return acc.(int) + n.(int)
+}
// A stream of the natural numbers: 0, 1, 2, 3, ...
type integerStream struct {}
@@ -107,6 +110,13 @@ func TestFind(t *testing.T) {
}
}
+func TestInject(t *testing.T) {
+ res := Inject(oneToFive, 0, adder);
+ if res.(int) != 15 {
+ t.Errorf("Inject(oneToFive, 0, adder) = %v, want 15", res)
+ }
+}
+
func TestMap(t *testing.T) {
res := Data(Map(Map(oneToFive, doubler), addOne));
assertArraysAreEqual(t, res, []int{ 3, 5, 7, 9, 11 })