-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday6_test.go
97 lines (77 loc) · 1.93 KB
/
day6_test.go
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGroupCheck(t *testing.T) {
groupAnswers := "abcx abcy abcz"
customForm := makeCustomsForm(groupAnswers)
assert.Equal(t, 6, len(customForm.AnyoneAnsweredYes()))
}
func TestExampleInput(t *testing.T) {
rawPlaneAnswers := []string{
"abc",
"",
"a",
"b",
"c",
"",
"ab",
"ac",
"",
"a",
"a",
"a",
"a",
"",
"b",
}
records := make(chan string)
go fixInput(rawPlaneAnswers, records)
group1 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a', 'b', 'c'}, group1.AnyoneAnsweredYes())
group2 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a', 'b', 'c'}, group2.AnyoneAnsweredYes())
group3 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a', 'b', 'c'}, group3.AnyoneAnsweredYes())
group4 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a'}, group4.AnyoneAnsweredYes())
group5 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'b'}, group5.AnyoneAnsweredYes())
}
func TestExampleInputPart2(t *testing.T) {
rawPlaneAnswers := []string{
"abc",
"",
"a",
"b",
"c",
"",
"ab",
"ac",
"",
"a",
"a",
"a",
"a",
"",
"b",
}
records := make(chan string)
go fixInput(rawPlaneAnswers, records)
group1 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a', 'b', 'c'}, group1.EveryoneAnsweredYes())
group2 := makeCustomsForm(<-records)
assert.Equal(t, []rune{}, group2.EveryoneAnsweredYes())
group3 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a'}, group3.EveryoneAnsweredYes())
group4 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'a'}, group4.EveryoneAnsweredYes())
group5 := makeCustomsForm(<-records)
assert.Equal(t, []rune{'b'}, group5.EveryoneAnsweredYes())
}
func TestMakeForm(t *testing.T) {
groupAnswers := "abcx abcy abcz"
customForm := makeCustomsForm(groupAnswers)
assert.Equal(t, []rune{'a', 'b', 'c', 'x', 'y', 'z'}, customForm.AnyoneAnsweredYes())
}