summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-12-20 22:40:09 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-12-20 22:40:09 +0100
commit579f3c771bcebed3e9b145c1cb0f7d7054a94e37 (patch)
treee2f1f96d7a8607cd1e4542de0899829a915e888b
parent306580731b95d74b3f497c7bdbee0c77230a0a4e (diff)
Subtests
-rw-r--r--flood_test.go95
1 files changed, 47 insertions, 48 deletions
diff --git a/flood_test.go b/flood_test.go
index 952b35f..6e7e846 100644
--- a/flood_test.go
+++ b/flood_test.go
@@ -2,54 +2,53 @@ package main
import "testing"
-type floodTest struct {
- Input string
- Result bool
-}
-
-var floodTestData = []floodTest{
- {
- Input: `! ! ! ! ! ! ! !`,
- Result: true,
- },
- {
- Input: `test test test test abc abc`,
- Result: true,
- },
- {
- Input: `! test ! test ! test ! test !`,
- Result: true,
- },
- {
- Input: `a b c d e f g h i j`,
- Result: false,
- },
- {
- Input: `const union __infinity_un __infinity = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };`,
- Result: false,
- },
- {
- Input: `a = b > 3 ? 2 : 4`,
- Result: false,
- },
- {
- Input: `AAAAAAAAAAAAAAAAAAAA`,
- Result: true,
- },
- {
- Input: `AAAAAAAAAABBBBBBBBBB`,
- Result: true,
- },
- {
- Input: `ivy 3 3 rho (iota 9) in 2 6 7 8 9`,
- Result: false,
- },
-}
-
func TestFlood(t *testing.T) {
- for _, test := range floodTestData {
- if isFlood(test.Input) != test.Result {
- t.Error(test.Input, "expected", test.Result)
- }
+ testCases := []struct {
+ Input string
+ Result bool
+ }{
+ {
+ Input: `! ! ! ! ! ! ! !`,
+ Result: true,
+ },
+ {
+ Input: `test test test test abc abc`,
+ Result: true,
+ },
+ {
+ Input: `! test ! test ! test ! test !`,
+ Result: true,
+ },
+ {
+ Input: `a b c d e f g h i j`,
+ Result: false,
+ },
+ {
+ Input: `const union __infinity_un __infinity = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };`,
+ Result: false,
+ },
+ {
+ Input: `a = b > 3 ? 2 : 4`,
+ Result: false,
+ },
+ {
+ Input: `AAAAAAAAAAAAAAAAAAAA`,
+ Result: true,
+ },
+ {
+ Input: `AAAAAAAAAABBBBBBBBBB`,
+ Result: true,
+ },
+ {
+ Input: `ivy 3 3 rho (iota 9) in 2 6 7 8 9`,
+ Result: false,
+ },
+ }
+ for _, tc := range testCases {
+ t.Run(tc.Input, func(t *testing.T) {
+ if isFlood(tc.Input) != tc.Result {
+ t.Errorf("want %v", tc.Result)
+ }
+ })
}
}