Codebase list golang-github-go-openapi-swag / fresh-releases/upstream convert_types_test.go
fresh-releases/upstream

Tree @fresh-releases/upstream (Download .tar.gz)

convert_types_test.go @fresh-releases/upstreamraw · history · blame

  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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
// Copyright 2015 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swag

import (
	"reflect"
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

func assertSingleValue(t *testing.T, inElem, elem reflect.Value, expectPointer bool, idx int) {
	if !assert.Truef(t,
		(elem.Kind() == reflect.Ptr) == expectPointer,
		"Unexpected expectPointer=%t value type", expectPointer) {
		return
	}
	if inElem.Kind() == reflect.Ptr && !inElem.IsNil() {
		inElem = reflect.Indirect(inElem)
	}
	if elem.Kind() == reflect.Ptr && !elem.IsNil() {
		elem = reflect.Indirect(elem)
	}

	if !assert.Truef(t,
		(elem.Kind() == reflect.Ptr && elem.IsNil()) || IsZero(elem.Interface()) ==
			(inElem.Kind() == reflect.Ptr && inElem.IsNil()) || IsZero(inElem.Interface()),
		"Unexpected nil pointer at idx %d", idx) {
		return
	}

	if !((elem.Kind() == reflect.Ptr && elem.IsNil()) || IsZero(elem.Interface())) {
		if !assert.IsTypef(t, inElem.Interface(), elem.Interface(), "Expected in/out to match types") {
			return
		}
		assert.EqualValuesf(t, inElem.Interface(), elem.Interface(), "Unexpected value at idx %d: %v", idx, elem.Interface())
	}
}

// assertValues checks equivalent representation pointer vs values for single var, slices and maps
func assertValues(t *testing.T, in, out interface{}, expectPointer bool, idx int) {
	vin := reflect.ValueOf(in)
	vout := reflect.ValueOf(out)
	switch vin.Kind() {
	case reflect.Slice, reflect.Map:
		if !assert.Equalf(t, vin.Kind(), vout.Kind(), "Unexpected output type at idx %d", idx) ||
			!assert.Equalf(t, vin.Len(), vout.Len(), "Unexpected len at idx %d", idx) {
			break
		}
		var elem, inElem reflect.Value
		for i := 0; i < vin.Len(); i++ {
			if vin.Kind() == reflect.Slice {
				elem = vout.Index(i)
				inElem = vin.Index(i)
			} else if vin.Kind() == reflect.Map {
				keys := vin.MapKeys()
				elem = vout.MapIndex(keys[i])
				inElem = vout.MapIndex(keys[i])
			}
			assertSingleValue(t, inElem, elem, expectPointer, idx)
		}
	default:
		inElem := vin
		elem := vout
		assertSingleValue(t, inElem, elem, expectPointer, idx)
	}
}

var testCasesStringSlice = [][]string{
	{"a", "b", "c", "d", "e"},
	{"a", "b", "", "", "e"},
}

func TestStringSlice(t *testing.T) {
	for idx, in := range testCasesStringSlice {
		if in == nil {
			continue
		}
		out := StringSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := StringValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesStringValueSlice = [][]*string{
	{String("a"), String("b"), nil, String("c")},
}

func TestStringValueSlice(t *testing.T) {
	for idx, in := range testCasesStringValueSlice {
		if in == nil {
			continue
		}
		out := StringValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := StringSlice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesStringMap = []map[string]string{
	{"a": "1", "b": "2", "c": "3"},
}

func TestStringMap(t *testing.T) {
	for idx, in := range testCasesStringMap {
		if in == nil {
			continue
		}
		out := StringMap(in)
		assertValues(t, in, out, true, idx)

		out2 := StringValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesBoolSlice = [][]bool{
	{true, true, false, false},
}

func TestBoolSlice(t *testing.T) {
	for idx, in := range testCasesBoolSlice {
		if in == nil {
			continue
		}
		out := BoolSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := BoolValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesBoolValueSlice = [][]*bool{
	{Bool(true), Bool(true), Bool(false), Bool(false)},
}

func TestBoolValueSlice(t *testing.T) {
	for idx, in := range testCasesBoolValueSlice {
		if in == nil {
			continue
		}
		out := BoolValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := BoolSlice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesBoolMap = []map[string]bool{
	{"a": true, "b": false, "c": true},
}

func TestBoolMap(t *testing.T) {
	for idx, in := range testCasesBoolMap {
		if in == nil {
			continue
		}
		out := BoolMap(in)
		assertValues(t, in, out, true, idx)

		out2 := BoolValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesIntSlice = [][]int{
	{1, 2, 3, 4},
}

func TestIntSlice(t *testing.T) {
	for idx, in := range testCasesIntSlice {
		if in == nil {
			continue
		}
		out := IntSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := IntValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesIntValueSlice = [][]*int{
	{Int(1), Int(2), Int(3), Int(4)},
}

func TestIntValueSlice(t *testing.T) {
	for idx, in := range testCasesIntValueSlice {
		if in == nil {
			continue
		}
		out := IntValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := IntSlice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesIntMap = []map[string]int{
	{"a": 3, "b": 2, "c": 1},
}

func TestIntMap(t *testing.T) {
	for idx, in := range testCasesIntMap {
		if in == nil {
			continue
		}
		out := IntMap(in)
		assertValues(t, in, out, true, idx)

		out2 := IntValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesInt64Slice = [][]int64{
	{1, 2, 3, 4},
}

func TestInt64Slice(t *testing.T) {
	for idx, in := range testCasesInt64Slice {
		if in == nil {
			continue
		}
		out := Int64Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Int64ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesInt64ValueSlice = [][]*int64{
	{Int64(1), Int64(2), Int64(3), Int64(4)},
}

func TestInt64ValueSlice(t *testing.T) {
	for idx, in := range testCasesInt64ValueSlice {
		if in == nil {
			continue
		}
		out := Int64ValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := Int64Slice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesInt64Map = []map[string]int64{
	{"a": 3, "b": 2, "c": 1},
}

func TestInt64Map(t *testing.T) {
	for idx, in := range testCasesInt64Map {
		if in == nil {
			continue
		}
		out := Int64Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Int64ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesFloat32Slice = [][]float32{
	{1, 2, 3, 4},
}

func TestFloat32Slice(t *testing.T) {
	for idx, in := range testCasesFloat32Slice {
		if in == nil {
			continue
		}

		out := Float32Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Float32ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesFloat64Slice = [][]float64{
	{1, 2, 3, 4},
}

func TestFloat64Slice(t *testing.T) {
	for idx, in := range testCasesFloat64Slice {
		if in == nil {
			continue
		}
		out := Float64Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Float64ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUintSlice = [][]uint{
	{1, 2, 3, 4},
}

func TestUintSlice(t *testing.T) {
	for idx, in := range testCasesUintSlice {
		if in == nil {
			continue
		}
		out := UintSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := UintValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUintValueSlice = [][]*uint{}

func TestUintValueSlice(t *testing.T) {
	for idx, in := range testCasesUintValueSlice {
		if in == nil {
			continue
		}
		out := UintValueSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := UintSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUintMap = []map[string]uint{
	{"a": 3, "b": 2, "c": 1},
}

func TestUintMap(t *testing.T) {
	for idx, in := range testCasesUintMap {
		if in == nil {
			continue
		}
		out := UintMap(in)
		assertValues(t, in, out, true, idx)

		out2 := UintValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint16Slice = [][]uint16{
	{1, 2, 3, 4},
}

func TestUint16Slice(t *testing.T) {
	for idx, in := range testCasesUint16Slice {
		if in == nil {
			continue
		}

		out := Uint16Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint16ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint16ValueSlice = [][]*uint16{}

func TestUint16ValueSlice(t *testing.T) {
	for idx, in := range testCasesUint16ValueSlice {
		if in == nil {
			continue
		}

		out := Uint16ValueSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint16Slice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint16Map = []map[string]uint16{
	{"a": 3, "b": 2, "c": 1},
}

func TestUint16Map(t *testing.T) {
	for idx, in := range testCasesUint16Map {
		if in == nil {
			continue
		}

		out := Uint16Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint16ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint64Slice = [][]uint64{
	{1, 2, 3, 4},
}

func TestUint64Slice(t *testing.T) {
	for idx, in := range testCasesUint64Slice {
		if in == nil {
			continue
		}
		out := Uint64Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint64ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint64ValueSlice = [][]*uint64{}

func TestUint64ValueSlice(t *testing.T) {
	for idx, in := range testCasesUint64ValueSlice {
		if in == nil {
			continue
		}
		out := Uint64ValueSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint64Slice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint64Map = []map[string]uint64{
	{"a": 3, "b": 2, "c": 1},
}

func TestUint64Map(t *testing.T) {
	for idx, in := range testCasesUint64Map {
		if in == nil {
			continue
		}
		out := Uint64Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint64ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesFloat32ValueSlice = [][]*float32{}

func TestFloat32ValueSlice(t *testing.T) {
	for idx, in := range testCasesFloat32ValueSlice {
		if in == nil {
			continue
		}

		out := Float32ValueSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := Float32Slice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesFloat32Map = []map[string]float32{
	{"a": 3, "b": 2, "c": 1},
}

func TestFloat32Map(t *testing.T) {
	for idx, in := range testCasesFloat32Map {
		if in == nil {
			continue
		}

		out := Float32Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Float32ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesFloat64ValueSlice = [][]*float64{}

func TestFloat64ValueSlice(t *testing.T) {
	for idx, in := range testCasesFloat64ValueSlice {
		if in == nil {
			continue
		}
		out := Float64ValueSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := Float64Slice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesFloat64Map = []map[string]float64{
	{"a": 3, "b": 2, "c": 1},
}

func TestFloat64Map(t *testing.T) {
	for idx, in := range testCasesFloat64Map {
		if in == nil {
			continue
		}
		out := Float64Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Float64ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesTimeSlice = [][]time.Time{
	{time.Now(), time.Now().AddDate(100, 0, 0)},
}

func TestTimeSlice(t *testing.T) {
	for idx, in := range testCasesTimeSlice {
		if in == nil {
			continue
		}
		out := TimeSlice(in)
		assertValues(t, in, out, true, idx)

		out2 := TimeValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesTimeValueSlice = [][]*time.Time{
	{Time(time.Now()), Time(time.Now().AddDate(100, 0, 0))},
}

func TestTimeValueSlice(t *testing.T) {
	for idx, in := range testCasesTimeValueSlice {
		if in == nil {
			continue
		}
		out := TimeValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := TimeSlice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesTimeMap = []map[string]time.Time{
	{"a": time.Now().AddDate(-100, 0, 0), "b": time.Now()},
}

func TestTimeMap(t *testing.T) {
	for idx, in := range testCasesTimeMap {
		if in == nil {
			continue
		}
		out := TimeMap(in)
		assertValues(t, in, out, true, idx)

		out2 := TimeValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesInt32Slice = [][]int32{
	{1, 2, 3, 4},
}

func TestInt32Slice(t *testing.T) {
	for idx, in := range testCasesInt32Slice {
		if in == nil {
			continue
		}
		out := Int32Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Int32ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesInt32ValueSlice = [][]*int32{
	{Int32(1), Int32(2), Int32(3), Int32(4)},
}

func TestInt32ValueSlice(t *testing.T) {
	for idx, in := range testCasesInt32ValueSlice {
		if in == nil {
			continue
		}
		out := Int32ValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := Int32Slice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesInt32Map = []map[string]int32{
	{"a": 3, "b": 2, "c": 1},
}

func TestInt32Map(t *testing.T) {
	for idx, in := range testCasesInt32Map {
		if in == nil {
			continue
		}
		out := Int32Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Int32ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint32Slice = [][]uint32{
	{1, 2, 3, 4},
}

func TestUint32Slice(t *testing.T) {
	for idx, in := range testCasesUint32Slice {
		if in == nil {
			continue
		}
		out := Uint32Slice(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint32ValueSlice(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesUint32ValueSlice = [][]*uint32{
	{Uint32(1), Uint32(2), Uint32(3), Uint32(4)},
}

func TestUint32ValueSlice(t *testing.T) {
	for idx, in := range testCasesUint32ValueSlice {
		if in == nil {
			continue
		}
		out := Uint32ValueSlice(in)
		assertValues(t, in, out, false, idx)

		out2 := Uint32Slice(out)
		assertValues(t, in, out2, true, idx)
	}
}

var testCasesUint32Map = []map[string]uint32{
	{"a": 3, "b": 2, "c": 1},
}

func TestUint32Map(t *testing.T) {
	for idx, in := range testCasesUint32Map {
		if in == nil {
			continue
		}
		out := Uint32Map(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint32ValueMap(out)
		assertValues(t, in, out2, false, idx)
	}
}

var testCasesString = []string{"a", "b", "c", "d", "e", ""}

func TestStringValue(t *testing.T) {
	for idx, in := range testCasesString {
		out := String(in)
		assertValues(t, in, out, true, idx)

		out2 := StringValue(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, StringValue(nil), "expected conversion from nil to return zero value")
}

var testCasesBool = []bool{true, false}

func TestBoolValue(t *testing.T) {
	for idx, in := range testCasesBool {
		out := Bool(in)
		assertValues(t, in, out, true, idx)

		out2 := BoolValue(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, BoolValue(nil), "expected conversion from nil to return zero value")
}

var testCasesInt = []int{1, 2, 3, 0}

func TestIntValue(t *testing.T) {
	for idx, in := range testCasesInt {
		out := Int(in)
		assertValues(t, in, out, true, idx)

		out2 := IntValue(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, IntValue(nil), "expected conversion from nil to return zero value")
}

var testCasesInt32 = []int32{1, 2, 3, 0}

func TestInt32Value(t *testing.T) {
	for idx, in := range testCasesInt32 {
		out := Int32(in)
		assertValues(t, in, out, true, idx)

		out2 := Int32Value(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, Int32Value(nil), "expected conversion from nil to return zero value")
}

var testCasesInt64 = []int64{1, 2, 3, 0}

func TestInt64Value(t *testing.T) {
	for idx, in := range testCasesInt64 {
		out := Int64(in)
		assertValues(t, in, out, true, idx)

		out2 := Int64Value(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, Int64Value(nil), "expected conversion from nil to return zero value")
}

var testCasesUint = []uint{1, 2, 3, 0}

func TestUintValue(t *testing.T) {
	for idx, in := range testCasesUint {
		out := Uint(in)
		assertValues(t, in, out, true, idx)

		out2 := UintValue(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, UintValue(nil), "expected conversion from nil to return zero value")
}

var testCasesUint32 = []uint32{1, 2, 3, 0}

func TestUint32Value(t *testing.T) {
	for idx, in := range testCasesUint32 {
		out := Uint32(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint32Value(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, Uint32Value(nil), "expected conversion from nil to return zero value")
}

var testCasesUint64 = []uint64{1, 2, 3, 0}

func TestUint64Value(t *testing.T) {
	for idx, in := range testCasesUint64 {
		out := Uint64(in)
		assertValues(t, in, out, true, idx)

		out2 := Uint64Value(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, Uint64Value(nil), "expected conversion from nil to return zero value")
}

var testCasesFloat32 = []float32{1, 2, 3, 0}

func TestFloat32Value(t *testing.T) {
	for idx, in := range testCasesFloat32 {
		out := Float32(in)
		assertValues(t, in, out, true, idx)

		out2 := Float32Value(out)
		assertValues(t, in, out2, false, idx)
	}

	assert.Zerof(t, Float32Value(nil), "expected conversion from nil to return zero value")
}

var testCasesFloat64 = []float64{1, 2, 3, 0}

func TestFloat64Value(t *testing.T) {
	for idx, in := range testCasesFloat64 {
		out := Float64(in)
		assertValues(t, in, out, true, idx)

		out2 := Float64Value(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, Float64Value(nil), "expected conversion from nil to return zero value")
}

var testCasesTime = []time.Time{
	time.Now().AddDate(-100, 0, 0), time.Now(),
}

func TestTimeValue(t *testing.T) {
	for idx, in := range testCasesTime {
		out := Time(in)
		assertValues(t, in, out, true, idx)

		out2 := TimeValue(out)
		assertValues(t, in, out2, false, idx)
	}
	assert.Zerof(t, TimeValue(nil), "expected conversion from nil to return zero value")
}