-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
91 lines (82 loc) · 1.44 KB
/
Copy pathmain_test.go
File metadata and controls
91 lines (82 loc) · 1.44 KB
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
package main
import (
"testing"
file "github.com/shaunburdick/advent-of-code-2024/lib/file"
)
type TestDeclaration struct {
name string
input string
want int
run bool
}
var example1 = `1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet`
func Test_day0_part1(t *testing.T) {
tests := []TestDeclaration{
{
name: "example",
input: example1,
want: 142,
run: true,
},
{
name: "actual",
input: input,
want: 52974,
run: file.ExistsRelativeFile("input.txt"),
},
}
for _, tt := range tests {
if tt.run {
t.Run(tt.name, func(t *testing.T) {
if got := part1(tt.input); got != tt.want {
t.Errorf("part1() = %v, want %v", got, tt.want)
}
})
}
}
}
func Benchmark_day0_part1(b *testing.B) {
for i := 0; i < b.N; i++ {
part1(example1)
}
}
var example2 = `two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen`
func Test_day0_part2(t *testing.T) {
tests := []TestDeclaration{
{
name: "example",
input: example2,
want: 281,
run: true,
},
{
name: "actual",
input: input,
want: 53340,
run: file.ExistsRelativeFile("input.txt"),
},
}
for _, tt := range tests {
if tt.run {
t.Run(tt.name, func(t *testing.T) {
if got := part2(tt.input); got != tt.want {
t.Errorf("part2() = %v, want %v", got, tt.want)
}
})
}
}
}
func Benchmark_day0_part2(b *testing.B) {
for i := 0; i < b.N; i++ {
part2(example2)
}
}