@@ -22,17 +22,11 @@ import (
22
22
"testing"
23
23
)
24
24
25
- var emptyArrayList = Arraylist {
26
- elements : []any {},
27
- size : 0 ,
28
- }
29
-
30
- var notEmptyArrayList = Arraylist {
31
- elements : []any {"hello" , "world" },
32
- size : 2 ,
33
- }
34
-
35
25
func TestArraylist_Add (t * testing.T ) {
26
+ emptyArrayList := Arraylist {
27
+ elements : []any {},
28
+ size : 0 ,
29
+ }
36
30
type fields struct {
37
31
elements []any
38
32
size int
@@ -65,6 +59,10 @@ func TestArraylist_Add(t *testing.T) {
65
59
}
66
60
67
61
func TestArraylist_Contains (t * testing.T ) {
62
+ arrayList := & Arraylist {
63
+ elements : []any {"hello" , "world" },
64
+ size : 2 ,
65
+ }
68
66
type fields struct {
69
67
elements []any
70
68
size int
@@ -82,8 +80,8 @@ func TestArraylist_Contains(t *testing.T) {
82
80
}{
83
81
{
84
82
fields : fields {
85
- elements : notEmptyArrayList .elements ,
86
- size : notEmptyArrayList .size ,
83
+ elements : arrayList .elements ,
84
+ size : arrayList .size ,
87
85
},
88
86
args : args {element : "hello" },
89
87
want : true ,
@@ -108,6 +106,10 @@ func TestArraylist_Contains(t *testing.T) {
108
106
}
109
107
110
108
func TestArraylist_Empty (t * testing.T ) {
109
+ emptyArrayList := Arraylist {
110
+ elements : []any {},
111
+ size : 0 ,
112
+ }
111
113
type fields struct {
112
114
elements []any
113
115
size int
@@ -139,6 +141,10 @@ func TestArraylist_Empty(t *testing.T) {
139
141
}
140
142
141
143
func TestArraylist_Get (t * testing.T ) {
144
+ arrayList := & Arraylist {
145
+ elements : []any {"hello" , "world" },
146
+ size : 2 ,
147
+ }
142
148
type fields struct {
143
149
elements []any
144
150
size int
@@ -154,8 +160,8 @@ func TestArraylist_Get(t *testing.T) {
154
160
}{
155
161
{
156
162
fields : fields {
157
- elements : notEmptyArrayList .elements ,
158
- size : notEmptyArrayList .size ,
163
+ elements : arrayList .elements ,
164
+ size : arrayList .size ,
159
165
},
160
166
args : args {index : 0 },
161
167
want : "hello" ,
@@ -175,6 +181,10 @@ func TestArraylist_Get(t *testing.T) {
175
181
}
176
182
177
183
func TestArraylist_IndexOf (t * testing.T ) {
184
+ arrayList := & Arraylist {
185
+ elements : []any {"hello" , "world" },
186
+ size : 2 ,
187
+ }
178
188
type fields struct {
179
189
elements []any
180
190
size int
@@ -190,8 +200,8 @@ func TestArraylist_IndexOf(t *testing.T) {
190
200
}{
191
201
{
192
202
fields : fields {
193
- elements : notEmptyArrayList .elements ,
194
- size : notEmptyArrayList .size ,
203
+ elements : arrayList .elements ,
204
+ size : arrayList .size ,
195
205
},
196
206
args : args {"hello" },
197
207
want : 0 ,
@@ -212,8 +222,8 @@ func TestArraylist_IndexOf(t *testing.T) {
212
222
213
223
func TestArraylist_Remove (t * testing.T ) {
214
224
arrayList := & Arraylist {
215
- elements : notEmptyArrayList . elements ,
216
- size : notEmptyArrayList . size ,
225
+ elements : [] any { "hello" , "world" } ,
226
+ size : 2 ,
217
227
}
218
228
type fields struct {
219
229
elements []any
@@ -251,6 +261,10 @@ func TestArraylist_Remove(t *testing.T) {
251
261
}
252
262
253
263
func TestArraylist_Size (t * testing.T ) {
264
+ arrayList := & Arraylist {
265
+ elements : []any {"hello" , "world" },
266
+ size : 2 ,
267
+ }
254
268
type fields struct {
255
269
elements []any
256
270
size int
@@ -262,8 +276,8 @@ func TestArraylist_Size(t *testing.T) {
262
276
}{
263
277
{
264
278
fields : fields {
265
- elements : notEmptyArrayList .elements ,
266
- size : notEmptyArrayList .size ,
279
+ elements : arrayList .elements ,
280
+ size : arrayList .size ,
267
281
},
268
282
want : 2 ,
269
283
},
@@ -282,6 +296,10 @@ func TestArraylist_Size(t *testing.T) {
282
296
}
283
297
284
298
func TestArraylist_find (t * testing.T ) {
299
+ arrayList := & Arraylist {
300
+ elements : []any {"hello" , "world" },
301
+ size : 2 ,
302
+ }
285
303
type fields struct {
286
304
elements []any
287
305
size int
@@ -298,8 +316,8 @@ func TestArraylist_find(t *testing.T) {
298
316
}{
299
317
{
300
318
fields : fields {
301
- elements : notEmptyArrayList .elements ,
302
- size : notEmptyArrayList .size ,
319
+ elements : arrayList .elements ,
320
+ size : arrayList .size ,
303
321
},
304
322
args : args {element : "hello" },
305
323
want : true ,
@@ -324,6 +342,10 @@ func TestArraylist_find(t *testing.T) {
324
342
}
325
343
326
344
func TestNew (t * testing.T ) {
345
+ arrayList := & Arraylist {
346
+ elements : []any {"hello" , "world" },
347
+ size : 2 ,
348
+ }
327
349
type args struct {
328
350
elements []any
329
351
}
@@ -334,7 +356,7 @@ func TestNew(t *testing.T) {
334
356
want * Arraylist
335
357
}{
336
358
{
337
- args : args {notEmptyArrayList .elements },
359
+ args : args {arrayList .elements },
338
360
want : New ("hello" , "world" ),
339
361
},
340
362
}
0 commit comments