summaryrefslogtreecommitdiff
path: root/go/series/asktoomuch_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/asktoomuch_test.go
parent8caa9002f4a9ab7a95d73aca5b185ec1da1da6ac (diff)
Solve series
Diffstat (limited to 'go/series/asktoomuch_test.go')
-rw-r--r--go/series/asktoomuch_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/go/series/asktoomuch_test.go b/go/series/asktoomuch_test.go
new file mode 100644
index 0000000..e29703a
--- /dev/null
+++ b/go/series/asktoomuch_test.go
@@ -0,0 +1,29 @@
+// +build asktoomuch
+
+package slice
+
+import "testing"
+
+func TestAskTooMuch(t *testing.T) {
+ test := allTests[0]
+ defer func() {
+ if recover() != nil {
+ t.Fatalf("Yikes, UnsafeFirst(%d, %s) panicked!", test.n, test.s)
+ }
+ }()
+ for _, test = range allTests {
+ switch res := UnsafeFirst(test.n, test.s); {
+ case len(test.out) > 0: // well, this should work
+ if res != test.out[0] {
+ t.Fatalf("Yikes, UnsafeFirst(%d, %s) = %q, want %q.",
+ test.n, test.s, res, test.out[0])
+ }
+ case len(res) != test.n:
+ t.Fatalf("Yikes, UnsafeFirst(%d, %s) = %q, but %q doesn't have %d characters.",
+ test.n, test.s, res, res, test.n)
+ default:
+ t.Fatalf("Yikes, UnsafeFirst(%d, %s) = %q, but %q isn't in %q",
+ test.n, test.s, res, res, test.s)
+ }
+ }
+}