@@ -8,39 +8,31 @@ import (
8
8
"testing"
9
9
)
10
10
11
- type gridTestCase struct {
12
- name string
11
+ var gridTestCases = map [string ]struct {
13
12
gridScoringActions []gridScoringAction
14
13
expectedAutoGamePiecePoints int
15
14
expectedTeleopGamePiecePoints int
16
15
expectedSuperchargedPoints int
17
16
expectedLinks []Link
18
17
expectedIsCoopertitionThresholdAchieved bool
19
18
expectedIsFull bool
20
- }
21
-
22
- var gridTestCases = []gridTestCase {
23
- {
24
- name : "No scoring actions" ,
25
- },
26
- {
27
- name : "Same node scored multiple times in auto" ,
19
+ }{
20
+ "No scoring actions" : {},
21
+ "Same node scored multiple times in auto" : {
28
22
gridScoringActions : []gridScoringAction {
29
23
{rowTop , 7 , TwoCubes , true },
30
24
},
31
25
expectedAutoGamePiecePoints : 6 ,
32
26
expectedTeleopGamePiecePoints : 0 ,
33
27
},
34
- {
35
- name : "Same node scored multiple times in teleop" ,
28
+ "Same node scored multiple times in teleop" : {
36
29
gridScoringActions : []gridScoringAction {
37
30
{rowTop , 7 , TwoCubes , false },
38
31
},
39
32
expectedAutoGamePiecePoints : 0 ,
40
33
expectedTeleopGamePiecePoints : 5 ,
41
34
},
42
- {
43
- name : "Grid with many pieces but no links and no co-op bonus" ,
35
+ "Grid with many pieces but no links and no co-op bonus" : {
44
36
gridScoringActions : []gridScoringAction {
45
37
{rowBottom , 0 , Cone , true },
46
38
{rowBottom , 1 , Cone , false },
@@ -60,8 +52,7 @@ var gridTestCases = []gridTestCase{
60
52
expectedAutoGamePiecePoints : 22 ,
61
53
expectedTeleopGamePiecePoints : 30 ,
62
54
},
63
- {
64
- name : "Non-aligned links" ,
55
+ "Non-aligned links" : {
65
56
gridScoringActions : []gridScoringAction {
66
57
{rowMiddle , 1 , Cube , false },
67
58
{rowMiddle , 2 , Cone , false },
@@ -78,8 +69,7 @@ var gridTestCases = []gridTestCase{
78
69
},
79
70
expectedIsCoopertitionThresholdAchieved : true ,
80
71
},
81
- {
82
- name : "Coopertition threshold achieved across multiple rows" ,
72
+ "Coopertition threshold achieved across multiple rows" : {
83
73
gridScoringActions : []gridScoringAction {
84
74
{rowBottom , 3 , Cone , true },
85
75
{rowMiddle , 4 , Cube , false },
@@ -89,8 +79,7 @@ var gridTestCases = []gridTestCase{
89
79
expectedTeleopGamePiecePoints : 3 ,
90
80
expectedIsCoopertitionThresholdAchieved : true ,
91
81
},
92
- {
93
- name : "Coopertition threshold not achieved due to wrong game piece" ,
82
+ "Coopertition threshold not achieved due to wrong game piece" : {
94
83
gridScoringActions : []gridScoringAction {
95
84
{rowBottom , 3 , Cone , true },
96
85
{rowMiddle , 4 , Cube , false },
@@ -100,8 +89,7 @@ var gridTestCases = []gridTestCase{
100
89
expectedTeleopGamePiecePoints : 3 ,
101
90
expectedIsCoopertitionThresholdAchieved : false ,
102
91
},
103
- {
104
- name : "Full grid without supercharging" ,
92
+ "Full grid without supercharging" : {
105
93
gridScoringActions : []gridScoringAction {
106
94
{rowBottom , 0 , Cone , true },
107
95
{rowBottom , 1 , Cone , false },
@@ -147,8 +135,7 @@ var gridTestCases = []gridTestCase{
147
135
expectedIsCoopertitionThresholdAchieved : true ,
148
136
expectedIsFull : true ,
149
137
},
150
- {
151
- name : "Full grid with supercharging" ,
138
+ "Full grid with supercharging" : {
152
139
gridScoringActions : []gridScoringAction {
153
140
{rowBottom , 0 , ConeThenCube , true },
154
141
{rowBottom , 1 , Cone , false },
@@ -195,8 +182,7 @@ var gridTestCases = []gridTestCase{
195
182
expectedIsCoopertitionThresholdAchieved : true ,
196
183
expectedIsFull : true ,
197
184
},
198
- {
199
- name : "Invalid scoring actions are ignored" ,
185
+ "Invalid scoring actions are ignored" : {
200
186
gridScoringActions : []gridScoringAction {
201
187
{rowMiddle , 0 , Cube , false },
202
188
{rowMiddle , 1 , Cone , true },
@@ -221,17 +207,15 @@ var gridTestCases = []gridTestCase{
221
207
}
222
208
223
209
func TestGrid (t * testing.T ) {
224
- for _ , testCase := range gridTestCases {
210
+ for name , testCase := range gridTestCases {
225
211
grid := buildTestGrid (testCase .gridScoringActions )
226
212
227
- assert .Equal (t , testCase .expectedAutoGamePiecePoints , grid .AutoGamePiecePoints (), testCase .name )
228
- assert .Equal (t , testCase .expectedTeleopGamePiecePoints , grid .TeleopGamePiecePoints (), testCase .name )
229
- assert .Equal (t , testCase .expectedSuperchargedPoints , grid .SuperchargedPoints (), testCase .name )
230
- assert .Equal (t , 5 * len (testCase .expectedLinks ), grid .LinkPoints (), testCase .name )
231
- assert .Equal (t , testCase .expectedLinks , grid .Links (), testCase .name )
232
- assert .Equal (
233
- t , testCase .expectedIsCoopertitionThresholdAchieved , grid .IsCoopertitionThresholdAchieved (), testCase .name ,
234
- )
235
- assert .Equal (t , testCase .expectedIsFull , grid .IsFull (), testCase .name )
213
+ assert .Equal (t , testCase .expectedAutoGamePiecePoints , grid .AutoGamePiecePoints (), name )
214
+ assert .Equal (t , testCase .expectedTeleopGamePiecePoints , grid .TeleopGamePiecePoints (), name )
215
+ assert .Equal (t , testCase .expectedSuperchargedPoints , grid .SuperchargedPoints (), name )
216
+ assert .Equal (t , 5 * len (testCase .expectedLinks ), grid .LinkPoints (), name )
217
+ assert .Equal (t , testCase .expectedLinks , grid .Links (), name )
218
+ assert .Equal (t , testCase .expectedIsCoopertitionThresholdAchieved , grid .IsCoopertitionThresholdAchieved (), name )
219
+ assert .Equal (t , testCase .expectedIsFull , grid .IsFull (), name )
236
220
}
237
221
}
0 commit comments