github.com/leanovate/gopter@v0.2.9/gen/complex_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 TestComplex128Shrinker(t *testing.T) { 11 zeroShrinks := gen.Complex128Shrinker(0 + 0i).All() 12 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 13 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 14 } 15 16 oneShrink := gen.Complex128Shrinker(1 + 0i).All() 17 if !reflect.DeepEqual(oneShrink, []interface{}{ 18 (0 + 0i), (0.5 + 0i), (-0.5 + 0i), (0.75 + 0i), (-0.75 + 0i), (0.875 + 0i), (-0.875 + 0i), 19 (0.9375 + 0i), (-0.9375 + 0i), (0.96875 + 0i), (-0.96875 + 0i), (0.984375 + 0i), 20 (-0.984375 + 0i), (0.9921875 + 0i), (-0.9921875 + 0i), (0.99609375 + 0i), 21 (-0.99609375 + 0i), (0.998046875 + 0i), (-0.998046875 + 0i), (0.9990234375 + 0i), 22 (-0.9990234375 + 0i), (0.99951171875 + 0i), (-0.99951171875 + 0i), (0.999755859375 + 0i), 23 (-0.999755859375 + 0i), (0.9998779296875 + 0i), (-0.9998779296875 + 0i), 24 (0.99993896484375 + 0i), (-0.99993896484375 + 0i), (0.999969482421875 + 0i), 25 (-0.999969482421875 + 0i), (0.9999847412109375 + 0i), (-0.9999847412109375 + 0i), 26 }) { 27 t.Errorf("Invalid oneShrink: %#v", oneShrink) 28 } 29 30 iShrink := gen.Complex128Shrinker(1i).All() 31 if !reflect.DeepEqual(iShrink, []interface{}{ 32 (0 + 0i), (0 + 0.5i), (0 - 0.5i), (0 + 0.75i), (0 - 0.75i), (0 + 0.875i), (0 - 0.875i), 33 (0 + 0.9375i), (0 - 0.9375i), (0 + 0.96875i), (0 - 0.96875i), (0 + 0.984375i), 34 (0 - 0.984375i), (0 + 0.9921875i), (0 - 0.9921875i), (0 + 0.99609375i), (0 - 0.99609375i), 35 (0 + 0.998046875i), (0 - 0.998046875i), (0 + 0.9990234375i), (0 - 0.9990234375i), 36 (0 + 0.99951171875i), (0 - 0.99951171875i), (0 + 0.999755859375i), (0 - 0.999755859375i), 37 (0 + 0.9998779296875i), (0 - 0.9998779296875i), (0 + 0.99993896484375i), 38 (0 - 0.99993896484375i), (0 + 0.999969482421875i), (0 - 0.999969482421875i), 39 (0 + 0.9999847412109375i), (0 - 0.9999847412109375i), 40 }) { 41 t.Errorf("Invalid iShrink: %#v", iShrink) 42 } 43 44 teniShrink := gen.Complex128Shrinker(10 + 1i).All() 45 if !reflect.DeepEqual(teniShrink, []interface{}{(0 + 1i), (10 + 0i), (5 + 1i), (10 + 0.5i), 46 (-5 + 1i), (10 - 0.5i), (7.5 + 1i), (10 + 0.75i), (-7.5 + 1i), (10 - 0.75i), (8.75 + 1i), 47 (10 + 0.875i), (-8.75 + 1i), (10 - 0.875i), (9.375 + 1i), (10 + 0.9375i), (-9.375 + 1i), 48 (10 - 0.9375i), (9.6875 + 1i), (10 + 0.96875i), (-9.6875 + 1i), (10 - 0.96875i), 49 (9.84375 + 1i), (10 + 0.984375i), (-9.84375 + 1i), (10 - 0.984375i), (9.921875 + 1i), 50 (10 + 0.9921875i), (-9.921875 + 1i), (10 - 0.9921875i), (9.9609375 + 1i), 51 (10 + 0.99609375i), (-9.9609375 + 1i), (10 - 0.99609375i), (9.98046875 + 1i), 52 (10 + 0.998046875i), (-9.98046875 + 1i), (10 - 0.998046875i), (9.990234375 + 1i), 53 (10 + 0.9990234375i), (-9.990234375 + 1i), (10 - 0.9990234375i), (9.9951171875 + 1i), 54 (10 + 0.99951171875i), (-9.9951171875 + 1i), (10 - 0.99951171875i), (9.99755859375 + 1i), 55 (10 + 0.999755859375i), (-9.99755859375 + 1i), (10 - 0.999755859375i), 56 (9.998779296875 + 1i), (10 + 0.9998779296875i), (-9.998779296875 + 1i), 57 (10 - 0.9998779296875i), (9.9993896484375 + 1i), (10 + 0.99993896484375i), 58 (-9.9993896484375 + 1i), (10 - 0.99993896484375i), (9.99969482421875 + 1i), 59 (10 + 0.999969482421875i), (-9.99969482421875 + 1i), (10 - 0.999969482421875i), 60 (9.999847412109375 + 1i), (10 + 0.9999847412109375i), (-9.999847412109375 + 1i), 61 (10 - 0.9999847412109375i), (9.999923706054688 + 1i), (-9.999923706054688 + 1i), 62 (9.999961853027344 + 1i), (-9.999961853027344 + 1i), (9.999980926513672 + 1i), 63 (-9.999980926513672 + 1i), 64 }) { 65 t.Errorf("Invalid teniShrink: %#v", teniShrink) 66 } 67 } 68 69 func TestComplex64Shrinker(t *testing.T) { 70 zeroShrinks := gen.Complex64Shrinker(complex64(0 + 0i)).All() 71 if !reflect.DeepEqual(zeroShrinks, []interface{}{}) { 72 t.Errorf("Invalid zeroShrinks: %#v", zeroShrinks) 73 } 74 75 oneShrink := gen.Complex64Shrinker(complex64(1 + 0i)).All() 76 if !reflect.DeepEqual(oneShrink, []interface{}{ 77 complex64(0 + 0i), complex64(0.5 + 0i), complex64(-0.5 + 0i), complex64(0.75 + 0i), 78 complex64(-0.75 + 0i), complex64(0.875 + 0i), complex64(-0.875 + 0i), 79 complex64(0.9375 + 0i), complex64(-0.9375 + 0i), complex64(0.96875 + 0i), 80 complex64(-0.96875 + 0i), complex64(0.984375 + 0i), complex64(-0.984375 + 0i), 81 complex64(0.9921875 + 0i), complex64(-0.9921875 + 0i), complex64(0.99609375 + 0i), 82 complex64(-0.99609375 + 0i), complex64(0.9980469 + 0i), complex64(-0.9980469 + 0i), 83 complex64(0.99902344 + 0i), complex64(-0.99902344 + 0i), complex64(0.9995117 + 0i), 84 complex64(-0.9995117 + 0i), complex64(0.99975586 + 0i), complex64(-0.99975586 + 0i), 85 complex64(0.9998779 + 0i), complex64(-0.9998779 + 0i), complex64(0.99993896 + 0i), 86 complex64(-0.99993896 + 0i), complex64(0.9999695 + 0i), complex64(-0.9999695 + 0i), 87 complex64(0.99998474 + 0i), complex64(-0.99998474 + 0i), 88 }) { 89 t.Errorf("Invalid oneShrink: %#v", oneShrink) 90 } 91 }