-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathhighscore_test.go
More file actions
168 lines (145 loc) · 4.35 KB
/
Copy pathhighscore_test.go
File metadata and controls
168 lines (145 loc) · 4.35 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package validation
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHighscoreCategoryAchievementsString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighScoreAchievements
stringValue, err := highscoreCategory.String()
assert.Nil(err)
assert.Equal("achievements", stringValue)
assert.Equal(HighscoreCategory(1), highscoreCategory)
}
func TestHighscoreCategoryExperienceString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighScoreExperience
stringValue, err := highscoreCategory.String()
assert.Nil(err)
assert.Equal("experience", stringValue)
assert.Equal(HighscoreCategory(6), highscoreCategory)
}
func TestHighscoreCategoryDromescoreString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighScoreDromescore
stringValue, err := highscoreCategory.String()
assert.Nil(err)
assert.Equal("dromescore", stringValue)
assert.Equal(HighscoreCategory(14), highscoreCategory)
}
func TestHighscoreCategoryBosspointsString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighScoreBosspoints
stringValue, err := highscoreCategory.String()
assert.Nil(err)
assert.Equal("bosspoints", stringValue)
assert.Equal(HighscoreCategory(15), highscoreCategory)
}
func TestHighscoreCategoryBountypointsString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighScoreBountypoints
stringValue, err := highscoreCategory.String()
assert.Nil(err)
assert.Equal("bountypoints", stringValue)
assert.Equal(HighscoreCategory(16), highscoreCategory)
}
func TestHighscoreCategoryWeeklytasksString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighScoreWeeklytasks
stringValue, err := highscoreCategory.String()
assert.Nil(err)
assert.Equal("weeklytasks", stringValue)
assert.Equal(HighscoreCategory(17), highscoreCategory)
}
func TestHighscoreCategoryInvalidValueString(t *testing.T) {
assert := assert.New(t)
highscoreCategory := HighscoreCategory(99)
_, err := highscoreCategory.String()
assert.NotNil(err)
}
func TestHighscoreCategoryFromString(t *testing.T) {
assert := assert.New(t)
categoryTests := map[string]struct {
inputs []string
expected HighscoreCategory
}{
"Experience": {
inputs: []string{"experience", ""},
expected: HighScoreExperience,
},
"Achievements": {
inputs: []string{"achievements", "achievement"},
expected: HighScoreAchievements,
},
"Axefighting": {
inputs: []string{"axe", "axefighting"},
expected: HighScoreAxefighting,
},
"Charmpoints": {
inputs: []string{"charm", "charms", "charmpoints", "charmspoints"},
expected: HighScoreCharmpoints,
},
"Clubfighting": {
inputs: []string{"club", "clubfighting"},
expected: HighScoreClubfighting,
},
"Distancefighting": {
inputs: []string{"distance", "distancefighting"},
expected: HighScoreDistancefighting,
},
"Fishing": {
inputs: []string{"fishing"},
expected: HighScoreFishing,
},
"Fistfighting": {
inputs: []string{"fist", "fistfighting"},
expected: HighScoreFistfighting,
},
"Goshnarstaint": {
inputs: []string{"goshnar", "goshnars", "goshnarstaint"},
expected: HighScoreGoshnarstaint,
},
"Loyaltypoints": {
inputs: []string{"loyalty", "loyaltypoints"},
expected: HighScoreLoyaltypoints,
},
"Magiclevel": {
inputs: []string{"magic", "mlvl", "magiclevel"},
expected: HighScoreMagiclevel,
},
"Shielding": {
inputs: []string{"shielding", "shield"},
expected: HighScoreShielding,
},
"Swordfighting": {
inputs: []string{"sword", "swordfighting"},
expected: HighScoreSwordfighting,
},
"Dromescore": {
inputs: []string{"drome", "dromescore"},
expected: HighScoreDromescore,
},
"Bosspoints": {
inputs: []string{"boss", "bosses", "bosspoints"},
expected: HighScoreBosspoints,
},
"Bountypoints": {
inputs: []string{"bountypoints", "bountypoint", "bountypointsearned"},
expected: HighScoreBountypoints,
},
"Weeklytasks": {
inputs: []string{"weeklytasks", "weeklytask", "weeklytaskscompleted"},
expected: HighScoreWeeklytasks,
},
}
for category, data := range categoryTests {
t.Run(category, func(t *testing.T) {
for _, input := range data.inputs {
t.Run(input, func(t *testing.T) {
result := HighscoreCategoryFromString(input)
assert.Equal(data.expected, result, "unexpected result for input: %s", input)
})
}
})
}
}