-
Notifications
You must be signed in to change notification settings - Fork 3
/
day04_test.go
76 lines (70 loc) · 1.3 KB
/
day04_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
// Package main provides ...
package main
import (
"strconv"
"testing"
)
func TestSolve(t *testing.T) {
t.Run("It works", func(t *testing.T) {
got := Solve(200000, 300000)
want := 771
if got != want {
t.Errorf("got %v want %v", got, want)
}
})
}
func TestSolve2(t *testing.T) {
t.Run("It works", func(t *testing.T) {
got := Solve2(200000, 300000)
want := 546
if got != want {
t.Errorf("got %v want %v", got, want)
}
})
}
func TestIsPassword(t *testing.T) {
tests := []struct {
input int
output bool
}{
{111111, true},
{223450, false},
{123789, false},
{123444, true},
}
for _, test := range tests {
name := strconv.Itoa(test.input)
t.Run(name, func(t *testing.T) {
want := test.output
got := IsPassword(test.input)
if got != want {
t.Errorf("got %v want %v", got, want)
}
})
}
}
func TestIsPassword2(t *testing.T) {
tests := []struct {
input int
output bool
}{
{111111, false},
{223450, false},
{123789, false},
{123444, false},
{112233, true},
{123444, false},
{111122, true},
{111123, false},
}
for _, test := range tests {
name := strconv.Itoa(test.input)
t.Run(name, func(t *testing.T) {
want := test.output
got := IsPassword2(test.input)
if got != want {
t.Errorf("got %v want %v", got, want)
}
})
}
}