summaryrefslogtreecommitdiff
path: root/go/series/first_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-26 09:21:31 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-26 09:21:31 +0200
commit5905c68a1fbae71682ff2edea7c009ad0355e9fb (patch)
tree97c1979119448aa77e2f6f80e2ba2c16be3bf8bd /go/series/first_test.go
parent8caa9002f4a9ab7a95d73aca5b185ec1da1da6ac (diff)
Solve series
Diffstat (limited to 'go/series/first_test.go')
-rw-r--r--go/series/first_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/go/series/first_test.go b/go/series/first_test.go
new file mode 100644
index 0000000..cbe524b
--- /dev/null
+++ b/go/series/first_test.go
@@ -0,0 +1,23 @@
+// +build first
+
+package slice
+
+import "testing"
+
+func TestFirst(t *testing.T) {
+ for _, test := range allTests {
+ switch res, ok := First(test.n, test.s); {
+ case !ok:
+ if len(test.out) > 0 {
+ t.Fatalf("First(%d, %s) returned !ok, want ok.",
+ test.n, test.s)
+ }
+ case len(test.out) == 0:
+ t.Fatalf("First(%d, %s) = %s, %t. Expected ok == false",
+ test.n, test.s, res, ok)
+ case res != test.out[0]:
+ t.Fatalf("First(%d, %s) = %s. Want %s.",
+ test.n, test.s, res, test.out[0])
+ }
+ }
+}