-
Notifications
You must be signed in to change notification settings - Fork 28
/
plate_test.go
65 lines (61 loc) · 1.94 KB
/
plate_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
package brdoc
import (
"testing"
)
func TestIsPlate(t *testing.T) {
for i, tc := range []struct {
name string
expected bool
v string
}{
{"InvalidData_ShouldReturnFalse", false, "3467875434578764345789654"},
{"InvalidData_ShouldReturnFalse", false, ""},
{"InvalidData_ShouldReturnFalse", false, "AAAAAAA"},
{"ValidOldFormat_ShouldReturnTrue", true, "AAA0000"},
{"ValidOldFormat_ShouldReturnTrue", true, "ABC-1234"},
{"ValidNewFormat_ShouldReturnTrue", true, "AAA0A00"},
{"ValidNewFormat_ShouldReturnTrue", true, "ABC1D23"},
} {
t.Run(testName(i, tc.name), func(t *testing.T) {
assertEqual(t, tc.expected, IsPlate(tc.v))
})
}
}
func TestIsNationalPlate(t *testing.T) {
for i, tc := range []struct {
name string
expected bool
v string
}{
{"InvalidData_ShouldReturnFalse", false, "3467875434578764345789654"},
{"InvalidData_ShouldReturnFalse", false, ""},
{"InvalidData_ShouldReturnFalse", false, "AAAAAAA"},
{"InvalidNewFormat_ShouldReturnFlase", false, "AAA0A00"},
{"InvalidNewFormat_ShouldReturnFlase", false, "ABC1D23"},
{"ValidOldFormat_ShouldReturnTrue", true, "AAA0000"},
{"ValidOldFormat_ShouldReturnTrue", true, "ABC-1234"},
} {
t.Run(testName(i, tc.name), func(t *testing.T) {
assertEqual(t, tc.expected, IsNationalPlate(tc.v))
})
}
}
func TestIsMercosulPlate(t *testing.T) {
for i, tc := range []struct {
name string
expected bool
v string
}{
{"InvalidData_ShouldReturnFalse", false, "3467875434578764345789654"},
{"InvalidData_ShouldReturnFalse", false, ""},
{"InvalidData_ShouldReturnFalse", false, "AAAAAAA"},
{"InvalidOldFormat_ShouldReturnFlase", false, "AAA0000"},
{"InvalidOldFormat_ShouldReturnFlase", false, "ABC-1234"},
{"ValidNewFormat_ShouldReturnTrue", true, "AAA0A00"},
{"ValidNewFormat_ShouldReturnTrue", true, "ABC1D23"},
} {
t.Run(testName(i, tc.name), func(t *testing.T) {
assertEqual(t, tc.expected, IsMercosulPlate(tc.v))
})
}
}