github.com/leanovate/gopter@v0.2.9/gen/integers_shrink_test.go (about) 1 package gen_test 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/leanovate/gopter/gen" 8 ) 9 10 func TestInt64Shrink(t *testing.T) { 11 zeroShrinks := gen.Int64Shrinker(int64(0)).All() 12 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 13 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 14 } 15 16 tenShrinks := gen.Int64Shrinker(int64(10)).All() 17 if !reflect.DeepEqual(tenShrinks, []interface{}{int64(0), int64(5), int64(-5), int64(8), int64(-8), int64(9), int64(-9)}) { 18 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 19 } 20 21 negTenShrinks := gen.Int64Shrinker(int64(-10)).All() 22 if !reflect.DeepEqual(negTenShrinks, []interface{}{int64(0), int64(-5), int64(5), int64(-8), int64(8), int64(-9), int64(9)}) { 23 t.Errorf("Invalid negTenShrinks: %#v", negTenShrinks) 24 } 25 26 leetShrink := gen.Int64Shrinker(int64(1337)).All() 27 if !reflect.DeepEqual(leetShrink, []interface{}{ 28 int64(0), int64(669), int64(-669), int64(1003), int64(-1003), int64(1170), int64(-1170), 29 int64(1254), int64(-1254), int64(1296), int64(-1296), int64(1317), int64(-1317), 30 int64(1327), int64(-1327), int64(1332), int64(-1332), int64(1335), int64(-1335), 31 int64(1336), int64(-1336)}) { 32 t.Errorf("Invalid leetShrink: %#v", leetShrink) 33 } 34 } 35 36 func TestUInt64Shrink(t *testing.T) { 37 zeroShrinks := gen.UInt64Shrinker(uint64(0)).All() 38 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 39 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 40 } 41 42 tenShrinks := gen.UInt64Shrinker(uint64(10)).All() 43 if !reflect.DeepEqual(tenShrinks, []interface{}{uint64(0), uint64(5), uint64(8), uint64(9)}) { 44 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 45 } 46 47 leetShrink := gen.UInt64Shrinker(uint64(1337)).All() 48 if !reflect.DeepEqual(leetShrink, []interface{}{ 49 uint64(0), uint64(669), uint64(1003), uint64(1170), 50 uint64(1254), uint64(1296), uint64(1317), 51 uint64(1327), uint64(1332), uint64(1335), 52 uint64(1336)}) { 53 t.Errorf("Invalid leetShrink: %#v", leetShrink) 54 } 55 } 56 57 func TestInt32Shrink(t *testing.T) { 58 zeroShrinks := gen.Int32Shrinker(int32(0)).All() 59 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 60 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 61 } 62 63 tenShrinks := gen.Int32Shrinker(int32(10)).All() 64 if !reflect.DeepEqual(tenShrinks, []interface{}{int32(0), int32(5), int32(-5), int32(8), int32(-8), int32(9), int32(-9)}) { 65 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 66 } 67 } 68 69 func TestUInt32Shrink(t *testing.T) { 70 zeroShrinks := gen.UInt32Shrinker(uint32(0)).All() 71 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 72 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 73 } 74 75 tenShrinks := gen.UInt32Shrinker(uint32(10)).All() 76 if !reflect.DeepEqual(tenShrinks, []interface{}{uint32(0), uint32(5), uint32(8), uint32(9)}) { 77 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 78 } 79 } 80 81 func TestInt16Shrink(t *testing.T) { 82 zeroShrinks := gen.Int16Shrinker(int16(0)).All() 83 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 84 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 85 } 86 87 tenShrinks := gen.Int16Shrinker(int16(10)).All() 88 if !reflect.DeepEqual(tenShrinks, []interface{}{int16(0), int16(5), int16(-5), int16(8), int16(-8), int16(9), int16(-9)}) { 89 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 90 } 91 } 92 93 func TestUInt16Shrink(t *testing.T) { 94 zeroShrinks := gen.UInt16Shrinker(uint16(0)).All() 95 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 96 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 97 } 98 99 tenShrinks := gen.UInt16Shrinker(uint16(10)).All() 100 if !reflect.DeepEqual(tenShrinks, []interface{}{uint16(0), uint16(5), uint16(8), uint16(9)}) { 101 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 102 } 103 } 104 105 func TestInt8Shrink(t *testing.T) { 106 zeroShrinks := gen.Int8Shrinker(int8(0)).All() 107 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 108 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 109 } 110 111 tenShrinks := gen.Int8Shrinker(int8(10)).All() 112 if !reflect.DeepEqual(tenShrinks, []interface{}{int8(0), int8(5), int8(-5), int8(8), int8(-8), int8(9), int8(-9)}) { 113 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 114 } 115 } 116 117 func TestUInt8Shrink(t *testing.T) { 118 zeroShrinks := gen.UInt8Shrinker(uint8(0)).All() 119 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 120 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 121 } 122 123 tenShrinks := gen.UInt8Shrinker(uint8(10)).All() 124 if !reflect.DeepEqual(tenShrinks, []interface{}{uint8(0), uint8(5), uint8(8), uint8(9)}) { 125 t.Errorf("Invalid tenShrinks: %#v", tenShrinks) 126 } 127 }