summaryrefslogtreecommitdiff
path: root/flood_test.go
blob: 086292c574cb7a002c7d85705217b1f064f899de (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
package main

import "testing"

func TestFlood(t *testing.T) {
	testCases := []struct {
		line  string
		flood bool
	}{
		{
			line:  `! ! ! ! ! ! ! !`,
			flood: true,
		},
		{
			line:  `test test test test abc abc`,
			flood: true,
		},
		{
			line:  `! test ! test ! test ! test !`,
			flood: true,
		},
		{
			line:  `a b c d e f g h i j`,
			flood: false,
		},
		{
			line:  `const union __infinity_un __infinity = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };`,
			flood: false,
		},
		{
			line:  `a = b > 3 ? 2 : 4`,
			flood: false,
		},
		{
			line:  `AAAAAAAAAAAAAAAAAAAA`,
			flood: true,
		},
		{
			line:  `AAAAAAAAAABBBBBBBBBB`,
			flood: true,
		},
		{
			line:  `ivy 3 3 rho (iota 9) in 2 6 7 8 9`,
			flood: false,
		},
	}
	for _, tc := range testCases {
		t.Run(tc.line, func(t *testing.T) {
			if isFlood(tc.line) != tc.flood {
				t.Errorf("want %v", tc.flood)
			}
		})
	}
}