This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
117 lines (107 loc) · 3 KB
/
util_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package ow_stats
import "testing"
var keyTests = []struct {
n string // input
expected string // expected result
}{
{"Multikill - Best", "multikill_best"},
{"Soldier: 76", "soldier76"},
{"Lúcio", "lucio"},
}
var valueTests = []struct {
n string // input
expected float32 // expected result
}{
{"5", 5},
{"11,996", 11996},
{"50%", 0.5},
{"50 %", 0.5},
{"01:00:00", 1},
{"00:30:00", 0.5},
{"30:36", 0.51},
{"02:22", 0.0394444465637207},
{"1 hour", 1},
{"5 hours", 5},
{"14 hours", 14},
{"30 minutes", 0.5},
{"1 minute", 1 / 60.},
{"50 seconds", 50 / 3600.},
{"2.8 seconds", 2.8 / 3600.},
{"1 second", 1 / 3600.},
{"2.8", 2.8},
}
var pluralizerTests = []struct {
n string // input
expected string // expected result
}{
{"solo_kill", "solo_kills"},
{"solo_kills", "solo_kills"},
{"final_blow", "final_blows"},
{"final_blows", "final_blows"},
{"nano_boost_applied", "nano_boosts_applied"},
{"nano_boosts_applied", "nano_boosts_applied"},
{"final_blows_most_in_game", "final_blows_most_in_game"},
{"final_blow_most_in_game", "final_blows_most_in_game"},
{"projected_barriers_applied", "projected_barriers_applied"},
{"projected_barrier_applied", "projected_barriers_applied"},
{"multikills", "multikills"},
{"multikill", "multikills"},
{"eliminations_most_in_game", "eliminations_most_in_game"},
{"elimination_most_in_game", "eliminations_most_in_game"},
{"testblow_test", "testblow_test"},
{"kill_streak_best", "kill_streak_best"},
}
func TestUtil_SanitizeKey(t *testing.T) {
for _, tt := range keyTests {
actual := SanitizeKey(tt.n)
if actual != tt.expected {
t.Errorf("SanitizeKey(%s): expected %s, actual %s", tt.n, tt.expected, actual)
}
}
}
func TestUtil_SanitizeKey_Parallel(t *testing.T) {
for _, tt := range keyTests {
go func(input string, output string) {
actual := SanitizeKey(input)
if actual != output {
t.Errorf("SanitizeKey(%s): expected %s, actual %s", input, output, actual)
}
}(tt.n, tt.expected)
}
}
func TestUtil_SanitizeValue(t *testing.T) {
for _, tt := range valueTests {
actual := SanitizeValue(tt.n)
if actual != tt.expected {
t.Errorf("SanitizeValue(%s): expected %f, actual %f", tt.n, tt.expected, actual)
}
}
}
func TestUtil_SanitizeValue_Parallel(t *testing.T) {
for _, tt := range valueTests {
go func(input string, output float32) {
actual := SanitizeValue(input)
if actual != output {
t.Errorf("SanitizeValue(%s): expected %f, actual %f", input, output, actual)
}
}(tt.n, tt.expected)
}
}
func TestUtil_Pluralizer(t *testing.T) {
for _, tt := range pluralizerTests {
actual := Pluralizer(tt.n)
if actual != tt.expected {
t.Errorf("Pluralizer(%s): expected %s, actual %s", tt.n, tt.expected, actual)
}
}
}
func TestUtil_Pluralizer_Parallel(t *testing.T) {
for _, tt := range pluralizerTests {
go func(input string, output string) {
actual := Pluralizer(input)
if actual != output {
t.Errorf("Pluralizer(%s): expected %s, actual %s", input, output, actual)
}
}(tt.n, tt.expected)
}
}