github.com/sandwich-go/boost@v1.3.29/xmath/math_test.go (about) 1 // Code generated by tools. DO NOT EDIT. 2 package xmath 3 4 import ( 5 . "github.com/smartystreets/goconvey/convey" 6 "testing" 7 ) 8 9 func TestMath(t *testing.T) { 10 Convey("Float64Equals", t, func() { 11 So(Float64Equals(0.1, 0.2), ShouldBeFalse) 12 So(Float64Equals(0.1, 0.1+EPSILON64), ShouldBeTrue) 13 }) 14 15 Convey("Float32Equals", t, func() { 16 So(Float32Equals(0.1, 0.2), ShouldBeFalse) 17 So(Float32Equals(0.1, 0.1+EPSILON32), ShouldBeTrue) 18 }) 19 20 Convey("IsZeroFloat64", t, func() { 21 So(IsZeroFloat64(0.1), ShouldBeFalse) 22 So(IsZeroFloat64(0), ShouldBeTrue) 23 }) 24 25 Convey("IsZeroFloat32", t, func() { 26 So(IsZeroFloat32(0.1), ShouldBeFalse) 27 So(IsZeroFloat32(0), ShouldBeTrue) 28 }) 29 30 Convey("IsBelowZeroFloat64", t, func() { 31 So(IsBelowZeroFloat64(0.1), ShouldBeFalse) 32 So(IsBelowZeroFloat64(0), ShouldBeTrue) 33 So(IsBelowZeroFloat64(-0.1), ShouldBeTrue) 34 }) 35 36 Convey("IsBelowZeroFloat32", t, func() { 37 So(IsBelowZeroFloat32(0.1), ShouldBeFalse) 38 So(IsBelowZeroFloat32(0), ShouldBeTrue) 39 So(IsBelowZeroFloat32(-0.1), ShouldBeTrue) 40 }) 41 42 Convey("Float32", t, func() { 43 So(MaxFloat32(3.000000001, 3.000000002), ShouldEqual, 3.000000002) 44 So(MinFloat32(3.000000001, 3.000000002), ShouldEqual, 3.000000001) 45 So(AbsFloat32(3.000000001), ShouldEqual, 3.000000001) 46 So(AbsFloat32(-3.000000001), ShouldEqual, 3.000000001) 47 So(EffectZeroLimitFloat32(3.000000001, 0), ShouldEqual, 3.000000001) 48 So(EffectZeroLimitFloat32(3.000000001, -3.000000002), ShouldEqual, 0) 49 }) 50 51 Convey("Float64", t, func() { 52 So(MaxFloat64(3.000000001, 3.000000002), ShouldEqual, 3.000000002) 53 So(MinFloat64(3.000000001, 3.000000002), ShouldEqual, 3.000000001) 54 So(AbsFloat64(3.000000001), ShouldEqual, 3.000000001) 55 So(AbsFloat64(-3.000000001), ShouldEqual, 3.000000001) 56 So(EffectZeroLimitFloat64(3.000000001, 0), ShouldEqual, 3.000000001) 57 So(EffectZeroLimitFloat64(3.000000001, -3.000000002), ShouldEqual, 0) 58 }) 59 60 Convey("Int", t, func() { 61 So(MaxInt(3, 2), ShouldEqual, 3) 62 So(MinInt(3, 2), ShouldEqual, 2) 63 So(AbsInt(3), ShouldEqual, 3) 64 So(AbsInt(-3), ShouldEqual, 3) 65 So(EffectZeroLimitInt(3, 0), ShouldEqual, 3) 66 So(EffectZeroLimitInt(3, -4), ShouldEqual, 0) 67 }) 68 69 Convey("Int16", t, func() { 70 So(MaxInt16(3, 2), ShouldEqual, 3) 71 So(MinInt16(3, 2), ShouldEqual, 2) 72 So(AbsInt16(3), ShouldEqual, 3) 73 So(AbsInt16(-3), ShouldEqual, 3) 74 So(EffectZeroLimitInt16(3, 0), ShouldEqual, 3) 75 So(EffectZeroLimitInt16(3, -4), ShouldEqual, 0) 76 }) 77 78 Convey("Int32", t, func() { 79 So(MaxInt32(3, 2), ShouldEqual, 3) 80 So(MinInt32(3, 2), ShouldEqual, 2) 81 So(AbsInt32(3), ShouldEqual, 3) 82 So(AbsInt32(-3), ShouldEqual, 3) 83 So(EffectZeroLimitInt32(3, 0), ShouldEqual, 3) 84 So(EffectZeroLimitInt32(3, -4), ShouldEqual, 0) 85 }) 86 87 Convey("Int64", t, func() { 88 So(MaxInt64(3, 2), ShouldEqual, 3) 89 So(MinInt64(3, 2), ShouldEqual, 2) 90 So(AbsInt64(3), ShouldEqual, 3) 91 So(AbsInt64(-3), ShouldEqual, 3) 92 So(EffectZeroLimitInt64(3, 0), ShouldEqual, 3) 93 So(EffectZeroLimitInt64(3, -4), ShouldEqual, 0) 94 }) 95 96 Convey("Int8", t, func() { 97 So(MaxInt8(3, 2), ShouldEqual, 3) 98 So(MinInt8(3, 2), ShouldEqual, 2) 99 So(AbsInt8(3), ShouldEqual, 3) 100 So(AbsInt8(-3), ShouldEqual, 3) 101 So(EffectZeroLimitInt8(3, 0), ShouldEqual, 3) 102 So(EffectZeroLimitInt8(3, -4), ShouldEqual, 0) 103 }) 104 105 Convey("Uint", t, func() { 106 So(MaxUint(3, 2), ShouldEqual, 3) 107 So(MinUint(3, 2), ShouldEqual, 2) 108 }) 109 110 Convey("Uint16", t, func() { 111 So(MaxUint16(3, 2), ShouldEqual, 3) 112 So(MinUint16(3, 2), ShouldEqual, 2) 113 }) 114 115 Convey("Uint32", t, func() { 116 So(MaxUint32(3, 2), ShouldEqual, 3) 117 So(MinUint32(3, 2), ShouldEqual, 2) 118 }) 119 120 Convey("Uint64", t, func() { 121 So(MaxUint64(3, 2), ShouldEqual, 3) 122 So(MinUint64(3, 2), ShouldEqual, 2) 123 }) 124 125 Convey("Uint8", t, func() { 126 So(MaxUint8(3, 2), ShouldEqual, 3) 127 So(MinUint8(3, 2), ShouldEqual, 2) 128 }) 129 }