-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils_test.go
80 lines (71 loc) · 1.41 KB
/
utils_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
package habari
import (
"testing"
)
func TestIsNumberLike(t *testing.T) {
tests := []struct {
input string
want bool
}{
{"01", true},
{"01v2", true},
{"01x10", true},
{"05'", true},
{"1234v", false},
{"1234z", false},
{"test123", false},
{"1234Xv2", false},
{"125X'12", false},
{"12A34X", false},
{"", false},
}
for _, tc := range tests {
if got := isNumberLike(tc.input); got != tc.want {
t.Errorf("isNumberLike(%q) = %v; want %v", tc.input, got, tc.want)
}
}
}
func TestIsOrdinalNumber(t *testing.T) {
tests := []struct {
input string
want bool
}{
{"1st", true},
{"2nd", true},
{"3rd", true},
{"4th", true},
{"60th", true},
{"1234v", false},
{"1234z", false},
{"test123", false},
{"1234Xv2", false},
{"125X'12", false},
{"12A34X", false},
{"", false},
}
for _, tc := range tests {
if got := isOrdinalNumber(tc.input); got != tc.want {
t.Errorf("isOrdinalNumber(%q) = %v; want %v", tc.input, got, tc.want)
}
}
}
func TestIsResolution(t *testing.T) {
var tests = []struct {
input string
want bool
}{
{"1920x1080", true},
{"720p", true},
{"1080P", true},
{"1280x720", true},
{"FalseResolution1000x", false},
{"FalseResolutionp", false},
{"FalseResolutionP", false},
{"", false},
}
for _, test := range tests {
if got := isResolution(test.input); got != test.want {
t.Errorf("isResolution(%q) = %v", test.input, got)
}
}
}