-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
43 lines (36 loc) · 847 Bytes
/
main_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
package main
import "testing"
func TestHighestSeatID(t *testing.T) {
specs := []string{
"BFFFBBFRRR",
"FFFBBBFRRR",
"BBFFBBFRLL",
}
if got, want := highestSeatID(specs), 820; got != want {
t.Errorf("got %d, want %d", got, want)
}
}
func TestFindMissing(t *testing.T) {
s := []int{3, 4, 5, 7, 8, 9}
if got, want := findMissing(s), 6; got != want {
t.Errorf("got %d, want %d", got, want)
}
}
func TestParseSpec(t *testing.T) {
for n, tc := range []struct {
spec string
row, col, id int
}{
{"BFFFBBFRRR", 70, 7, 567},
{"FFFBBBFRRR", 14, 7, 119},
{"BBFFBBFRLL", 102, 4, 820},
} {
row, col, id := parseSpec(tc.spec)
if row != tc.row || col != tc.col || id != tc.id {
t.Errorf(
"[%d] parseSpec(%q) = %d, %d, %d, want %d, %d, %d",
n, tc.spec, row, col, id, tc.row, tc.col, tc.id,
)
}
}
}