Skip to content

Commit da2006a

Browse files
Sah, NandeshwarSah, Nandeshwar
authored andcommitted
Added function Set<Type>
1 parent 83cb1f9 commit da2006a

28 files changed

+1396
-290
lines changed

fp/difference_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,14 @@ func TestDifferenceBool(t *testing.T) {
530530
if len(actualPtr) != 0 {
531531
t.Errorf("DifferenceBoolPtr failed.")
532532
}
533-
533+
534534
expectedPtr := []*bool{&v8, &v2, &v1}
535535
actualPtr = DifferenceBoolPtr(expectedPtr)
536536

537537
if len(actualPtr) != 2 || !ExistsBoolPtr(&v8, actualPtr) || !ExistsBoolPtr(&v1, actualPtr) {
538538
t.Errorf("DifferenceBoolPtr failed. Expected=%v, actual=%v", expectedPtr, actualPtr)
539539
}
540-
540+
541541
list1Ptr := []*bool{&v8, &v2, &v1, &v1, &v2, &v8}
542542
list2Ptr := []*bool{&v1}
543543
actualPtr = DifferenceBoolPtr(list1Ptr, list2Ptr)

fp/dropwhileerr_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func TestDropWhileIntErr(t *testing.T) {
4141
}
4242
}
4343

44-
4544
func TestDropWhileInt64Err(t *testing.T) {
4645
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
4746

@@ -78,7 +77,6 @@ func TestDropWhileInt64Err(t *testing.T) {
7877
}
7978
}
8079

81-
8280
func TestDropWhileInt32Err(t *testing.T) {
8381
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
8482

@@ -115,7 +113,6 @@ func TestDropWhileInt32Err(t *testing.T) {
115113
}
116114
}
117115

118-
119116
func TestDropWhileInt16Err(t *testing.T) {
120117
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
121118

@@ -152,7 +149,6 @@ func TestDropWhileInt16Err(t *testing.T) {
152149
}
153150
}
154151

155-
156152
func TestDropWhileInt8Err(t *testing.T) {
157153
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
158154

@@ -189,7 +185,6 @@ func TestDropWhileInt8Err(t *testing.T) {
189185
}
190186
}
191187

192-
193188
func TestDropWhileUintErr(t *testing.T) {
194189
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
195190

@@ -226,7 +221,6 @@ func TestDropWhileUintErr(t *testing.T) {
226221
}
227222
}
228223

229-
230224
func TestDropWhileUint64Err(t *testing.T) {
231225
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
232226

@@ -263,7 +257,6 @@ func TestDropWhileUint64Err(t *testing.T) {
263257
}
264258
}
265259

266-
267260
func TestDropWhileUint32Err(t *testing.T) {
268261
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
269262

@@ -300,7 +293,6 @@ func TestDropWhileUint32Err(t *testing.T) {
300293
}
301294
}
302295

303-
304296
func TestDropWhileUint16Err(t *testing.T) {
305297
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
306298

@@ -337,7 +329,6 @@ func TestDropWhileUint16Err(t *testing.T) {
337329
}
338330
}
339331

340-
341332
func TestDropWhileUint8Err(t *testing.T) {
342333
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
343334

@@ -374,7 +365,6 @@ func TestDropWhileUint8Err(t *testing.T) {
374365
}
375366
}
376367

377-
378368
func TestDropWhileStrErr(t *testing.T) {
379369
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
380370

@@ -411,7 +401,6 @@ func TestDropWhileStrErr(t *testing.T) {
411401
}
412402
}
413403

414-
415404
func TestDropWhileBoolErr(t *testing.T) {
416405
var vt bool = true
417406
var vf bool = false
@@ -489,7 +478,6 @@ func TestDropWhileFloat32Err(t *testing.T) {
489478
}
490479
}
491480

492-
493481
func TestDropWhileFloat64Err(t *testing.T) {
494482
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
495483

@@ -525,4 +513,3 @@ func TestDropWhileFloat64Err(t *testing.T) {
525513
t.Errorf("DropWhileFloat64Err failed")
526514
}
527515
}
528-

fp/dropwhileptr_test.go

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func TestDropWhileIntPtr(t *testing.T) {
3535
}
3636
}
3737

38-
3938
func TestDropWhileInt64Ptr(t *testing.T) {
4039
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
4140

@@ -65,7 +64,6 @@ func TestDropWhileInt64Ptr(t *testing.T) {
6564
}
6665
}
6766

68-
6967
func TestDropWhileInt32Ptr(t *testing.T) {
7068
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
7169

@@ -95,7 +93,6 @@ func TestDropWhileInt32Ptr(t *testing.T) {
9593
}
9694
}
9795

98-
9996
func TestDropWhileInt16Ptr(t *testing.T) {
10097
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
10198

@@ -125,7 +122,6 @@ func TestDropWhileInt16Ptr(t *testing.T) {
125122
}
126123
}
127124

128-
129125
func TestDropWhileInt8Ptr(t *testing.T) {
130126
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
131127

@@ -155,7 +151,6 @@ func TestDropWhileInt8Ptr(t *testing.T) {
155151
}
156152
}
157153

158-
159154
func TestDropWhileUintPtr(t *testing.T) {
160155
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
161156

@@ -185,7 +180,6 @@ func TestDropWhileUintPtr(t *testing.T) {
185180
}
186181
}
187182

188-
189183
func TestDropWhileUint64Ptr(t *testing.T) {
190184
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
191185

@@ -215,7 +209,6 @@ func TestDropWhileUint64Ptr(t *testing.T) {
215209
}
216210
}
217211

218-
219212
func TestDropWhileUint32Ptr(t *testing.T) {
220213
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
221214

@@ -245,7 +238,6 @@ func TestDropWhileUint32Ptr(t *testing.T) {
245238
}
246239
}
247240

248-
249241
func TestDropWhileUint16Ptr(t *testing.T) {
250242
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
251243

@@ -275,7 +267,6 @@ func TestDropWhileUint16Ptr(t *testing.T) {
275267
}
276268
}
277269

278-
279270
func TestDropWhileUint8Ptr(t *testing.T) {
280271
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
281272

@@ -305,35 +296,32 @@ func TestDropWhileUint8Ptr(t *testing.T) {
305296
}
306297
}
307298

299+
func TestDropWhileStrPtr(t *testing.T) {
300+
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
301+
302+
var v2 string = "2"
303+
var v3 string = "3"
304+
var v4 string = "4"
305+
var v5 string = "5"
308306

307+
expectedNewList := []*string{&v3, &v4, &v5}
308+
NewList := DropWhileStrPtr(isEvenStrPtr, []*string{&v4, &v2, &v3, &v4, &v5})
309+
if *NewList[0] != *expectedNewList[0] || *NewList[1] != *expectedNewList[1] || *NewList[2] != *expectedNewList[2] {
310+
t.Errorf("DropWhileStrPtr failed. Expected New list=%v, actual list=%v", expectedNewList, NewList)
311+
}
309312

310-
func TestDropWhileStrPtr(t *testing.T) {
311-
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
312-
313-
var v2 string = "2"
314-
var v3 string = "3"
315-
var v4 string = "4"
316-
var v5 string = "5"
317-
318-
expectedNewList := []*string{&v3, &v4, &v5}
319-
NewList := DropWhileStrPtr(isEvenStrPtr, []*string{&v4, &v2, &v3, &v4, &v5})
320-
if *NewList[0] != *expectedNewList[0] || *NewList[1] != *expectedNewList[1] || *NewList[2] != *expectedNewList[2] {
321-
t.Errorf("DropWhileStrPtr failed. Expected New list=%v, actual list=%v", expectedNewList, NewList)
322-
}
323-
324-
if len(DropWhileStrPtr(nil, nil)) > 0 {
325-
t.Errorf("DropWhileStrPtr failed.")
326-
}
327-
328-
if len(DropWhileStrPtr(nil, []*string{})) > 0 {
329-
t.Errorf("DropWhileStrPtr failed.")
330-
}
331-
NewList = DropWhileStrPtr(isEvenStrPtr, []*string{&v4})
332-
if len(NewList) != 0 {
333-
t.Errorf("DropWhileStrPtr failed")
334-
}
313+
if len(DropWhileStrPtr(nil, nil)) > 0 {
314+
t.Errorf("DropWhileStrPtr failed.")
335315
}
336316

317+
if len(DropWhileStrPtr(nil, []*string{})) > 0 {
318+
t.Errorf("DropWhileStrPtr failed.")
319+
}
320+
NewList = DropWhileStrPtr(isEvenStrPtr, []*string{&v4})
321+
if len(NewList) != 0 {
322+
t.Errorf("DropWhileStrPtr failed")
323+
}
324+
}
337325

338326
func TestDropWhileBoolPtr(t *testing.T) {
339327
var vt bool = true
@@ -346,7 +334,6 @@ func TestDropWhileBoolPtr(t *testing.T) {
346334
}
347335
}
348336

349-
350337
func TestDropWhileFloat32Ptr(t *testing.T) {
351338
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
352339

@@ -376,7 +363,6 @@ func TestDropWhileFloat32Ptr(t *testing.T) {
376363
}
377364
}
378365

379-
380366
func TestDropWhileFloat64Ptr(t *testing.T) {
381367
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
382368

@@ -405,4 +391,3 @@ func TestDropWhileFloat64Ptr(t *testing.T) {
405391
t.Errorf("DropWhileFloat64Ptr failed")
406392
}
407393
}
408-

fp/dropwhileptrerr_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func TestDropWhileIntPtrErr(t *testing.T) {
4141
}
4242
}
4343

44-
4544
func TestDropWhileInt64PtrErr(t *testing.T) {
4645
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
4746

@@ -78,7 +77,6 @@ func TestDropWhileInt64PtrErr(t *testing.T) {
7877
}
7978
}
8079

81-
8280
func TestDropWhileInt32PtrErr(t *testing.T) {
8381
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
8482

@@ -115,7 +113,6 @@ func TestDropWhileInt32PtrErr(t *testing.T) {
115113
}
116114
}
117115

118-
119116
func TestDropWhileInt16PtrErr(t *testing.T) {
120117
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
121118

@@ -152,7 +149,6 @@ func TestDropWhileInt16PtrErr(t *testing.T) {
152149
}
153150
}
154151

155-
156152
func TestDropWhileInt8PtrErr(t *testing.T) {
157153
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
158154

@@ -189,7 +185,6 @@ func TestDropWhileInt8PtrErr(t *testing.T) {
189185
}
190186
}
191187

192-
193188
func TestDropWhileUintPtrErr(t *testing.T) {
194189
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
195190

@@ -226,7 +221,6 @@ func TestDropWhileUintPtrErr(t *testing.T) {
226221
}
227222
}
228223

229-
230224
func TestDropWhileUint64PtrErr(t *testing.T) {
231225
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
232226

@@ -263,7 +257,6 @@ func TestDropWhileUint64PtrErr(t *testing.T) {
263257
}
264258
}
265259

266-
267260
func TestDropWhileUint32PtrErr(t *testing.T) {
268261
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
269262

@@ -300,7 +293,6 @@ func TestDropWhileUint32PtrErr(t *testing.T) {
300293
}
301294
}
302295

303-
304296
func TestDropWhileUint16PtrErr(t *testing.T) {
305297
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
306298

@@ -337,7 +329,6 @@ func TestDropWhileUint16PtrErr(t *testing.T) {
337329
}
338330
}
339331

340-
341332
func TestDropWhileUint8PtrErr(t *testing.T) {
342333
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
343334

@@ -374,7 +365,6 @@ func TestDropWhileUint8PtrErr(t *testing.T) {
374365
}
375366
}
376367

377-
378368
func TestDropWhileStrPtrErr(t *testing.T) {
379369
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
380370

@@ -411,7 +401,6 @@ func TestDropWhileStrPtrErr(t *testing.T) {
411401
}
412402
}
413403

414-
415404
func TestDropWhileBoolPtrErr(t *testing.T) {
416405
var vt bool = true
417406
var vf bool = false
@@ -489,7 +478,6 @@ func TestDropWhileFloat32PtrErr(t *testing.T) {
489478
}
490479
}
491480

492-
493481
func TestDropWhileFloat64PtrErr(t *testing.T) {
494482
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
495483

@@ -525,4 +513,3 @@ func TestDropWhileFloat64PtrErr(t *testing.T) {
525513
t.Errorf("DropWhileFloat64PtrErr failed")
526514
}
527515
}
528-

fp/everyptr_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ func TestEveryUint8Ptr(t *testing.T) {
316316
}
317317
}
318318

319-
320319
func TestEveryStrPtr(t *testing.T) {
321320
// Test : every value in the list is even number
322321
var v2 string = "2"
@@ -346,7 +345,6 @@ func TestEveryStrPtr(t *testing.T) {
346345
}
347346
}
348347

349-
350348
func TestEveryBoolPtr(t *testing.T) {
351349
var vt bool = true
352350
var vf bool = false
@@ -362,7 +360,6 @@ func TestEveryBoolPtr(t *testing.T) {
362360
t.Errorf("EveryBoolPtr failed. Expected=true, actual=false")
363361
}
364362

365-
366363
list1 = []*bool{}
367364
if EveryBoolPtr(TruePtr, list1) {
368365
t.Errorf("EveryBool failed. Expected=false, actual=true")

0 commit comments

Comments
 (0)