summaryrefslogtreecommitdiff
path: root/flood_test.go
blob: 952b35f002930168e1bbd700fb3e18f9a84b163a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)
		}
	}
}