summaryrefslogtreecommitdiff
path: root/flood_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-08-15 14:56:21 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-08-15 14:56:21 +0200
commitef5ab7daa6a5df7794ed0b19a2092009e4adbaf8 (patch)
tree0aeb92ad8a8860f84e2c94462f8344c45bcf81be /flood_test.go
parent2cedfd17b76067124fe1b3455ad0f135a95e5390 (diff)
Add common word count
Diffstat (limited to 'flood_test.go')
-rw-r--r--flood_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/flood_test.go b/flood_test.go
new file mode 100644
index 0000000..47425ae
--- /dev/null
+++ b/flood_test.go
@@ -0,0 +1,43 @@
+package main
+
+import "testing"
+
+type floodTest struct {
+ Input string
+ Result bool
+}
+
+var floodTestData = []floodTest{
+ {
+ Input: `! ! ! ! ! ! ! !`,
+ Result: true,
+ },
+ {
+ Input: `test test test test`,
+ Result: true,
+ },
+ {
+ Input: `! test ! test ! test ! test !`,
+ Result: true,
+ },
+ {
+ Input: `a b c d e f g h i j`,
+ Result: true,
+ },
+ {
+ Input: `const union __infinity_un __infinity = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };`,
+ Result: false,
+ },
+ {
+ Input: `a = b > 3 ? 2 : 4`,
+ Result: false,
+ },
+}
+
+func TestFlood(t *testing.T) {
+ for _, test := range floodTestData {
+ if Flood(test.Input) != test.Result {
+ t.Error(test.Input, "expected", test.Result)
+ }
+ }
+}