let private BitAccuracy = 16
[<Literal>]
- let private EquivalenceTolerance = 0.0001f
+ let private EquivalenceTolerance = 0.00005f
let approxEq a b = MathHelper.ApproximatelyEquivalent(a, b, EquivalenceTolerance)
- //let approxEq a b = MathHelper.ApproximatelyEqual(a,b,BitAccuracy)
- //let approxEq a b = MathHelper.ApproximatelyEqualEpsilon(a,b,0.0001f)
+
+ let approxEqDelta a b = MathHelper.ApproximatelyEqual(a,b,BitAccuracy)
let approxEqSingleEpsilon a b = MathHelper.ApproximatelyEqualEpsilon(a, b, 0.00001f)
let approxEqDoubleEpsilon a b = MathHelper.ApproximatelyEqualEpsilon(a, b, 0.00001)
[<Sealed>]
type internal Assert =
- static member ApproximatelyEqual(a : Vector2,b : Vector2) =
+ static member ApproximatelyEquivalent(a : Vector2,b : Vector2) =
if not <| approxEq a.X b.X && approxEq a.Y b.Y then raise <| new Xunit.Sdk.EqualException(a,b)
- static member ApproximatelyEqual(a : Vector3,b : Vector3) =
+ static member ApproximatelyEquivalent(a : Vector3,b : Vector3) =
if not <| approxEq a.X b.X && approxEq a.Y b.Y && approxEq a.Z b.Z then raise <| new Xunit.Sdk.EqualException(a,b)
- static member ApproximatelyEqual(a : Vector4,b : Vector4) =
+ static member ApproximatelyEquivalent(a : Vector4,b : Vector4) =
if not <| approxEq a.X b.X && approxEq a.Y b.Y && approxEq a.Z b.Z && approxEq a.W b.W then
raise <| new Xunit.Sdk.EqualException(a,b)
- static member ApproximatelyEqual(a : float32,b : float32) =
+ static member ApproximatelyEquivalent(a : float32,b : float32) =
if not <| approxEq a b then raise <| new Xunit.Sdk.EqualException(a,b)
open OpenTK
module MathHelper =
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``ApproximatelyEqual (delta)`` =
/// This test ensures that approximately equal can never get it 'wrong' about the values.
[<Property>]
Assert.Equal(a,b)
Assert.True(MathHelper.ApproximatelyEqual(a,b,0))
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``ApproximatelyEqual (single-precision epsilon)`` =
//
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for large positive values``() =
- Assert.ApproximatelyEqualEpsilon(1000000.0f, 1000001.0f);
- Assert.ApproximatelyEqualEpsilon(1000001.0f, 1000000.0f);
+ Assert.ApproximatelyEquivalentEpsilon(1000000.0f, 1000001.0f);
+ Assert.ApproximatelyEquivalentEpsilon(1000001.0f, 1000000.0f);
Assert.NotApproximatelyEqualEpsilon(10000.0f, 10001.0f);
Assert.NotApproximatelyEqualEpsilon(10001.0f, 10000.0f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for large negative values``() =
- Assert.ApproximatelyEqualEpsilon(-1000000.0f, -1000001.0f);
- Assert.ApproximatelyEqualEpsilon(-1000001.0f, -1000000.0f);
+ Assert.ApproximatelyEquivalentEpsilon(-1000000.0f, -1000001.0f);
+ Assert.ApproximatelyEquivalentEpsilon(-1000001.0f, -1000000.0f);
Assert.NotApproximatelyEqualEpsilon(-10000.0f, -10001.0f);
Assert.NotApproximatelyEqualEpsilon(-10001.0f, -10000.0f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for positive values around 1``() =
- Assert.ApproximatelyEqualEpsilon(1.0000001f, 1.0000002f);
- Assert.ApproximatelyEqualEpsilon(1.0000002f, 1.0000001f);
+ Assert.ApproximatelyEquivalentEpsilon(1.0000001f, 1.0000002f);
+ Assert.ApproximatelyEquivalentEpsilon(1.0000002f, 1.0000001f);
Assert.NotApproximatelyEqualEpsilon(1.0002f, 1.0001f);
Assert.NotApproximatelyEqualEpsilon(1.0001f, 1.0002f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for negative values around -1``() =
- Assert.ApproximatelyEqualEpsilon(-1.000001f, -1.000002f);
- Assert.ApproximatelyEqualEpsilon(-1.000002f, -1.000001f);
+ Assert.ApproximatelyEquivalentEpsilon(-1.000001f, -1.000002f);
+ Assert.ApproximatelyEquivalentEpsilon(-1.000002f, -1.000001f);
Assert.NotApproximatelyEqualEpsilon(-1.0001f, -1.0002f);
Assert.NotApproximatelyEqualEpsilon(-1.0002f, -1.0001f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for values between 1 and 0``() =
- Assert.ApproximatelyEqualEpsilon(0.000000001000001f, 0.000000001000002f);
- Assert.ApproximatelyEqualEpsilon(0.000000001000002f, 0.000000001000001f);
+ Assert.ApproximatelyEquivalentEpsilon(0.000000001000001f, 0.000000001000002f);
+ Assert.ApproximatelyEquivalentEpsilon(0.000000001000002f, 0.000000001000001f);
Assert.NotApproximatelyEqualEpsilon(0.000000000001002f, 0.000000000001001f);
Assert.NotApproximatelyEqualEpsilon(0.000000000001001f, 0.000000000001002f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for values between -1 and 0``() =
- Assert.ApproximatelyEqualEpsilon(-0.000000001000001f, -0.000000001000002f);
- Assert.ApproximatelyEqualEpsilon(-0.000000001000002f, -0.000000001000001f);
+ Assert.ApproximatelyEquivalentEpsilon(-0.000000001000001f, -0.000000001000002f);
+ Assert.ApproximatelyEquivalentEpsilon(-0.000000001000002f, -0.000000001000001f);
Assert.NotApproximatelyEqualEpsilon(-0.000000000001002f, -0.000000000001001f);
Assert.NotApproximatelyEqualEpsilon(-0.000000000001001f, -0.000000000001002f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for comparisons involving 0``() =
- Assert.ApproximatelyEqualEpsilon(0.0f, 0.0f);
- Assert.ApproximatelyEqualEpsilon(0.0f, -0.0f);
- Assert.ApproximatelyEqualEpsilon(-0.0f, -0.0f);
+ Assert.ApproximatelyEquivalentEpsilon(0.0f, 0.0f);
+ Assert.ApproximatelyEquivalentEpsilon(0.0f, -0.0f);
+ Assert.ApproximatelyEquivalentEpsilon(-0.0f, -0.0f);
Assert.NotApproximatelyEqualEpsilon(0.00000001f, 0.0f);
Assert.NotApproximatelyEqualEpsilon(0.0f, 0.00000001f);
Assert.NotApproximatelyEqualEpsilon(-0.00000001f, 0.0f);
Assert.NotApproximatelyEqualEpsilon(0.0f, -0.00000001f);
- Assert.ApproximatelyEqualEpsilon(0.0f, 1e-40f, 0.01f);
- Assert.ApproximatelyEqualEpsilon(1e-40f, 0.0f, 0.01f);
+ Assert.ApproximatelyEquivalentEpsilon(0.0f, 1e-40f, 0.01f);
+ Assert.ApproximatelyEquivalentEpsilon(1e-40f, 0.0f, 0.01f);
Assert.NotApproximatelyEqualEpsilon(1e-40f, 0.0f, 0.000001f);
Assert.NotApproximatelyEqualEpsilon(0.0f, 1e-40f, 0.000001f);
- Assert.ApproximatelyEqualEpsilon(0.0f, -1e-40f, 0.1f);
- Assert.ApproximatelyEqualEpsilon(-1e-40f, 0.0f, 0.1f);
+ Assert.ApproximatelyEquivalentEpsilon(0.0f, -1e-40f, 0.1f);
+ Assert.ApproximatelyEquivalentEpsilon(-1e-40f, 0.0f, 0.1f);
Assert.NotApproximatelyEqualEpsilon(-1e-40f, 0.0f, 0.00000001f);
Assert.NotApproximatelyEqualEpsilon(0.0f, -1e-40f, 0.00000001f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for extreme values with overflow potential``() =
- Assert.ApproximatelyEqualEpsilon(System.Single.MaxValue, System.Single.MaxValue);
+ Assert.ApproximatelyEquivalentEpsilon(System.Single.MaxValue, System.Single.MaxValue);
Assert.NotApproximatelyEqualEpsilon(System.Single.MaxValue, -System.Single.MaxValue);
Assert.NotApproximatelyEqualEpsilon(-System.Single.MaxValue, System.Single.MaxValue);
Assert.NotApproximatelyEqualEpsilon(System.Single.MaxValue, System.Single.MaxValue / 2.0f);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for values involving infinities``() =
- Assert.ApproximatelyEqualEpsilon(System.Single.PositiveInfinity, System.Single.PositiveInfinity);
- Assert.ApproximatelyEqualEpsilon(System.Single.NegativeInfinity, System.Single.NegativeInfinity);
+ Assert.ApproximatelyEquivalentEpsilon(System.Single.PositiveInfinity, System.Single.PositiveInfinity);
+ Assert.ApproximatelyEquivalentEpsilon(System.Single.NegativeInfinity, System.Single.NegativeInfinity);
Assert.NotApproximatelyEqualEpsilon(System.Single.NegativeInfinity, System.Single.PositiveInfinity);
Assert.NotApproximatelyEqualEpsilon(System.Single.PositiveInfinity, System.Single.MaxValue);
Assert.NotApproximatelyEqualEpsilon(System.Single.NegativeInfinity, -System.Single.MaxValue);
Assert.NotApproximatelyEqualEpsilon(-1.0f, 1.000000001f);
Assert.NotApproximatelyEqualEpsilon(-1.000000001f, 1.0f);
Assert.NotApproximatelyEqualEpsilon(1.0f, -1.000000001f);
- Assert.ApproximatelyEqualEpsilon(10.0f * System.Single.Epsilon, 10.0f * -System.Single.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(10.0f * System.Single.Epsilon, 10.0f * -System.Single.Epsilon);
Assert.NotApproximatelyEqualEpsilon(10000.0f * System.Single.Epsilon, 10000.0f * -System.Single.Epsilon);
[<Fact>]
let ``ApproximatelyEqual (single precision) is correct for values very close to 0``() =
- Assert.ApproximatelyEqualEpsilon(System.Single.Epsilon, System.Single.Epsilon);
- Assert.ApproximatelyEqualEpsilon(System.Single.Epsilon, -System.Single.Epsilon);
- Assert.ApproximatelyEqualEpsilon(-System.Single.Epsilon, System.Single.Epsilon);
- Assert.ApproximatelyEqualEpsilon(System.Single.Epsilon, 0.0f);
- Assert.ApproximatelyEqualEpsilon(0.0f, System.Single.Epsilon);
- Assert.ApproximatelyEqualEpsilon(-System.Single.Epsilon, 0.0f);
- Assert.ApproximatelyEqualEpsilon(0.0f, -System.Single.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(System.Single.Epsilon, System.Single.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(System.Single.Epsilon, -System.Single.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(-System.Single.Epsilon, System.Single.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(System.Single.Epsilon, 0.0f);
+ Assert.ApproximatelyEquivalentEpsilon(0.0f, System.Single.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(-System.Single.Epsilon, 0.0f);
+ Assert.ApproximatelyEquivalentEpsilon(0.0f, -System.Single.Epsilon);
Assert.NotApproximatelyEqualEpsilon(0.000000001f, -System.Single.Epsilon);
Assert.NotApproximatelyEqualEpsilon(0.000000001f, System.Single.Epsilon);
Assert.NotApproximatelyEqualEpsilon(System.Single.Epsilon, 0.000000001f);
Assert.NotApproximatelyEqualEpsilon(-System.Single.Epsilon, 0.000000001f);
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``ApproximatelyEqual (double-precision epsilon)`` =
//
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for large positive values``() =
- Assert.ApproximatelyEqualEpsilon(1000000.0, 1000001.0);
- Assert.ApproximatelyEqualEpsilon(1000001.0, 1000000.0);
+ Assert.ApproximatelyEquivalentEpsilon(1000000.0, 1000001.0);
+ Assert.ApproximatelyEquivalentEpsilon(1000001.0, 1000000.0);
Assert.NotApproximatelyEqualEpsilon(10000.0, 10001.0);
Assert.NotApproximatelyEqualEpsilon(10001.0, 10000.0);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for large negative values``() =
- Assert.ApproximatelyEqualEpsilon(-1000000.0, -1000001.0);
- Assert.ApproximatelyEqualEpsilon(-1000001.0, -1000000.0);
+ Assert.ApproximatelyEquivalentEpsilon(-1000000.0, -1000001.0);
+ Assert.ApproximatelyEquivalentEpsilon(-1000001.0, -1000000.0);
Assert.NotApproximatelyEqualEpsilon(-10000.0, -10001.0);
Assert.NotApproximatelyEqualEpsilon(-10001.0, -10000.0);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for positive values around 1``() =
- Assert.ApproximatelyEqualEpsilon(1.0000001, 1.0000002);
- Assert.ApproximatelyEqualEpsilon(1.0000002, 1.0000001);
+ Assert.ApproximatelyEquivalentEpsilon(1.0000001, 1.0000002);
+ Assert.ApproximatelyEquivalentEpsilon(1.0000002, 1.0000001);
Assert.NotApproximatelyEqualEpsilon(1.0002, 1.0001);
Assert.NotApproximatelyEqualEpsilon(1.0001, 1.0002);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for negative values around -1``() =
- Assert.ApproximatelyEqualEpsilon(-1.000001, -1.000002);
- Assert.ApproximatelyEqualEpsilon(-1.000002, -1.000001);
+ Assert.ApproximatelyEquivalentEpsilon(-1.000001, -1.000002);
+ Assert.ApproximatelyEquivalentEpsilon(-1.000002, -1.000001);
Assert.NotApproximatelyEqualEpsilon(-1.0001, -1.0002);
Assert.NotApproximatelyEqualEpsilon(-1.0002, -1.0001);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for values between 1 and 0``() =
- Assert.ApproximatelyEqualEpsilon(0.000000001000001, 0.000000001000002);
- Assert.ApproximatelyEqualEpsilon(0.000000001000002, 0.000000001000001);
+ Assert.ApproximatelyEquivalentEpsilon(0.000000001000001, 0.000000001000002);
+ Assert.ApproximatelyEquivalentEpsilon(0.000000001000002, 0.000000001000001);
Assert.NotApproximatelyEqualEpsilon(0.000000000001002, 0.000000000001001);
Assert.NotApproximatelyEqualEpsilon(0.000000000001001, 0.000000000001002);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for values between -1 and 0``() =
- Assert.ApproximatelyEqualEpsilon(-0.000000001000001, -0.000000001000002);
- Assert.ApproximatelyEqualEpsilon(-0.000000001000002, -0.000000001000001);
+ Assert.ApproximatelyEquivalentEpsilon(-0.000000001000001, -0.000000001000002);
+ Assert.ApproximatelyEquivalentEpsilon(-0.000000001000002, -0.000000001000001);
Assert.NotApproximatelyEqualEpsilon(-0.000000000001002, -0.000000000001001);
Assert.NotApproximatelyEqualEpsilon(-0.000000000001001, -0.000000000001002);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for comparisons involving 0``() =
- Assert.ApproximatelyEqualEpsilon(0.0, 0.0);
- Assert.ApproximatelyEqualEpsilon(0.0, -0.0);
- Assert.ApproximatelyEqualEpsilon(-0.0, -0.0);
+ Assert.ApproximatelyEquivalentEpsilon(0.0, 0.0);
+ Assert.ApproximatelyEquivalentEpsilon(0.0, -0.0);
+ Assert.ApproximatelyEquivalentEpsilon(-0.0, -0.0);
Assert.NotApproximatelyEqualEpsilon(0.00000001, 0.0);
Assert.NotApproximatelyEqualEpsilon(0.0, 0.00000001);
Assert.NotApproximatelyEqualEpsilon(-0.00000001, 0.0);
Assert.NotApproximatelyEqualEpsilon(0.0, -0.00000001);
- Assert.ApproximatelyEqualEpsilon(0.0, 1e-310, 0.01);
- Assert.ApproximatelyEqualEpsilon(1e-310, 0.0, 0.01);
+ Assert.ApproximatelyEquivalentEpsilon(0.0, 1e-310, 0.01);
+ Assert.ApproximatelyEquivalentEpsilon(1e-310, 0.0, 0.01);
Assert.NotApproximatelyEqualEpsilon(1e-310, 0.0, 0.000001);
Assert.NotApproximatelyEqualEpsilon(0.0, 1e-310, 0.000001);
- Assert.ApproximatelyEqualEpsilon(0.0, -1e-310, 0.1);
- Assert.ApproximatelyEqualEpsilon(-1e-310, 0.0, 0.1);
+ Assert.ApproximatelyEquivalentEpsilon(0.0, -1e-310, 0.1);
+ Assert.ApproximatelyEquivalentEpsilon(-1e-310, 0.0, 0.1);
Assert.NotApproximatelyEqualEpsilon(-1e-310, 0.0, 0.00000001);
Assert.NotApproximatelyEqualEpsilon(0.0, -1e-310, 0.00000001);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for extreme values with overflow potential``() =
- Assert.ApproximatelyEqualEpsilon(System.Double.MaxValue, System.Double.MaxValue);
+ Assert.ApproximatelyEquivalentEpsilon(System.Double.MaxValue, System.Double.MaxValue);
Assert.NotApproximatelyEqualEpsilon(System.Double.MaxValue, -System.Double.MaxValue);
Assert.NotApproximatelyEqualEpsilon(-System.Double.MaxValue, System.Double.MaxValue);
Assert.NotApproximatelyEqualEpsilon(System.Double.MaxValue, System.Double.MaxValue / 2.0);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for values involving infinities``() =
- Assert.ApproximatelyEqualEpsilon(System.Double.PositiveInfinity, System.Double.PositiveInfinity);
- Assert.ApproximatelyEqualEpsilon(System.Double.NegativeInfinity, System.Double.NegativeInfinity);
+ Assert.ApproximatelyEquivalentEpsilon(System.Double.PositiveInfinity, System.Double.PositiveInfinity);
+ Assert.ApproximatelyEquivalentEpsilon(System.Double.NegativeInfinity, System.Double.NegativeInfinity);
Assert.NotApproximatelyEqualEpsilon(System.Double.NegativeInfinity, System.Double.PositiveInfinity);
Assert.NotApproximatelyEqualEpsilon(System.Double.PositiveInfinity, System.Double.MaxValue);
Assert.NotApproximatelyEqualEpsilon(System.Double.NegativeInfinity, -System.Double.MaxValue);
Assert.NotApproximatelyEqualEpsilon(-1.0, 1.000000001);
Assert.NotApproximatelyEqualEpsilon(-1.000000001, 1.0);
Assert.NotApproximatelyEqualEpsilon(1.0, -1.000000001);
- Assert.ApproximatelyEqualEpsilon(10.0 * System.Double.Epsilon, 10.0 * -System.Double.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(10.0 * System.Double.Epsilon, 10.0 * -System.Double.Epsilon);
Assert.NotApproximatelyEqualEpsilon(100000000000.0 * System.Double.Epsilon, 100000000000.0 * -System.Double.Epsilon);
[<Fact>]
let ``ApproximatelyEqual (double precision) is correct for values very close to 0``() =
- Assert.ApproximatelyEqualEpsilon(System.Double.Epsilon, System.Double.Epsilon);
- Assert.ApproximatelyEqualEpsilon(System.Double.Epsilon, -System.Double.Epsilon);
- Assert.ApproximatelyEqualEpsilon(-System.Double.Epsilon, System.Double.Epsilon);
- Assert.ApproximatelyEqualEpsilon(System.Double.Epsilon, 0.0);
- Assert.ApproximatelyEqualEpsilon(0.0, System.Double.Epsilon);
- Assert.ApproximatelyEqualEpsilon(-System.Double.Epsilon, 0.0);
- Assert.ApproximatelyEqualEpsilon(0.0, -System.Double.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(System.Double.Epsilon, System.Double.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(System.Double.Epsilon, -System.Double.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(-System.Double.Epsilon, System.Double.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(System.Double.Epsilon, 0.0);
+ Assert.ApproximatelyEquivalentEpsilon(0.0, System.Double.Epsilon);
+ Assert.ApproximatelyEquivalentEpsilon(-System.Double.Epsilon, 0.0);
+ Assert.ApproximatelyEquivalentEpsilon(0.0, -System.Double.Epsilon);
Assert.NotApproximatelyEqualEpsilon(0.000000001, -System.Double.Epsilon);
Assert.NotApproximatelyEqualEpsilon(0.000000001, System.Double.Epsilon);
Assert.NotApproximatelyEqualEpsilon(System.Double.Epsilon, 0.000000001);
Assert.NotApproximatelyEqualEpsilon(-System.Double.Epsilon, 0.000000001);
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``ApproximatelyEquivalent (tolerance diff)`` =
[<Fact>]
let ``ApproximatelyEquivalent correctly approximates equivalence where the difference falls below the tolerance``() =
Assert.True(MathHelper.ApproximatelyEquivalent(a, b, 0.0001f))
[<Fact>]
- let ``ApproximatelyEquivalent correctly approximates inequivalence where the difference is the tolerance``() =
+ let ``ApproximatelyEquivalent correctly approximates equivalence where the difference is the tolerance``() =
let a = 0.0001f
let b = 0.0002f
Assert.NotEqual(a,b)
- Assert.False(MathHelper.ApproximatelyEquivalent(a, b, 0.0001f))
+ Assert.True(MathHelper.ApproximatelyEquivalent(a, b, 0.0001f))
[<Fact>]
let ``ApproximatelyEquivalent correctly approximates inequivalence where the difference exceeds the tolerance``() =
[<Fact>]
let ``ApproximatelyEquivalent reports very different values as non-equal even with a high tolerance``() =
- let a = 2.0f
+ let a = 3.0f
let b = 1.0f
Assert.NotEqual(a,b)
Assert.False(MathHelper.ApproximatelyEquivalent(a, b, 1.0f))
open OpenTK
module Matrix4 =
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Constructors =
//
[<Property>]
Assert.Equal(o, A.M43)
Assert.Equal(p, A.M44)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Equality =
//
[<Property>]
let ``A matrix is not equal to an object which is not a matrix`` (a : Matrix4, b : Vector3) =
Assert.False(a.Equals(b))
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Multiplication =
//
[<Property>]
Assert.Equal(R4, AScaled.Row3)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Addition =
//
[<Property>]
Assert.Equal(o + o, sum.M43)
Assert.Equal(p + p, sum.M44)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Subtraction =
//
[<Property>]
Assert.Equal(o - o, sub.M43)
Assert.Equal(p - p, sub.M44)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Indexing =
//
[<Property>]
(fun() -> a.[1, 6] |> ignore) |> Assert.ThrowsIndexExn
(fun() -> a.[7, 12] |> ignore) |> Assert.ThrowsIndexExn
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Row and column properties`` =
//
[<Property>]
open OpenTK
module Vector2 =
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Constructors =
//
[<Property>]
Assert.Equal(x,v.X)
Assert.Equal(y,v.Y)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Clamping =
//
[<Property>]
Assert.Equal(expX, res.X)
Assert.Equal(expY, res.Y)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Length =
//
[<Property>]
Assert.Equal(lsq, v.LengthSquared)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Unit vectors and perpendicularity`` =
//
[<Property>]
Assert.Equal(perp, v.PerpendicularLeft)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Indexing =
//
[<Property>]
(fun() -> v.[2] |> ignore) |> Assert.ThrowsIndexExn
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Simple Properties`` =
//
[<Property>]
//
Assert.True(a.Length >= 0.0f)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Addition =
//
[<Property>]
let ``Vector addition is the same as component addition`` (a : Vector2,b : Vector2) =
let c = a + b
- Assert.ApproximatelyEqual(a.X + b.X,c.X)
- Assert.ApproximatelyEqual(a.Y + b.Y,c.Y)
+ Assert.ApproximatelyEquivalent(a.X + b.X,c.X)
+ Assert.ApproximatelyEquivalent(a.Y + b.Y,c.Y)
[<Property>]
let ``Vector addition is commutative`` (a : Vector2,b : Vector2) =
let c = a + b
let c2 = b + a
- Assert.ApproximatelyEqual(c,c2)
+ Assert.ApproximatelyEquivalent(c,c2)
[<Property>]
let ``Vector addition is associative`` (a : Vector2,b : Vector2,c : Vector2) =
let r1 = (a + b) + c
let r2 = a + (b + c)
- Assert.ApproximatelyEqual(r1,r2)
+ Assert.ApproximatelyEquivalent(r1,r2)
[<Property>]
let ``Static Vector2 addition method is the same as component addition`` (a : Vector2, b : Vector2) =
let v1 = Vector2(a.X + b.X, a.Y + b.Y)
let sum = Vector2.Add(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector2 addition method by reference is the same as component addition`` (a : Vector2, b : Vector2) =
let v1 = Vector2(a.X + b.X, a.Y + b.Y)
let sum = Vector2.Add(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Multiplication =
//
[<Property>]
let v1 = Vector2(a.X * b.X, a.Y * b.Y)
let sum = Vector2.Multiply(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector2 multiplication method by reference is the same as component multiplication`` (a : Vector2, b : Vector2) =
let v1 = Vector2(a.X * b.X, a.Y * b.Y)
let sum = Vector2.Multiply(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static method Vector2-scalar multiplication is the same as component-scalar multiplication`` (a : Vector2, f : float32) =
Assert.Equal(a.X * f,r.X)
Assert.Equal(a.Y * f,r.Y)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Subtraction =
//
[<Property>]
let v1 = Vector2(a.X - b.X, a.Y - b.Y)
let sum = Vector2.Subtract(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector2 subtraction method by reference is the same as component addition`` (a : Vector2, b : Vector2) =
let v1 = Vector2(a.X - b.X, a.Y - b.Y)
let sum = Vector2.Subtract(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Division =
//
[<Property>]
if not (approxEq f 0.0f) then
let r = a / f
- Assert.ApproximatelyEqual(a.X / f,r.X)
- Assert.ApproximatelyEqual(a.Y / f,r.Y)
+ Assert.ApproximatelyEquivalent(a.X / f,r.X)
+ Assert.ApproximatelyEquivalent(a.Y / f,r.Y)
[<Property>]
let ``Static Vector2-Vector2 division method is the same as component division`` (a : Vector2, b : Vector2) =
let v1 = Vector2(a.X / b.X, a.Y / b.Y)
let sum = Vector2.Divide(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector2-Vector2 divison method by reference `` (a : Vector2, b : Vector2) =
let v1 = Vector2(a.X / b.X, a.Y / b.Y)
let sum = Vector2.Divide(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector2-scalar division method is the same as component division`` (a : Vector2, b : float32) =
let v1 = Vector2(a.X / b, a.Y / b)
let sum = Vector2.Divide(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector2-scalar divison method by reference is the same as component division`` (a : Vector2, b : float32) =
let v1 = Vector2(a.X / b, a.Y / b)
let sum = Vector2.Divide(ref a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Negation =
//
[<Property>]
Assert.Equal(-x, vNeg.X)
Assert.Equal(-y, vNeg.Y)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Equality =
//
[<Property>]
Assert.True(equality)
Assert.False(inequalityByOtherType)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Swizzling =
//
[<Property>]
let v1yx = v1.Yx;
Assert.Equal(v2, v1yx);
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Interpolation =
//
[<Property>]
let vRes = Vector2.BaryCentric(ref a, ref b, ref c, u, v)
Assert.Equal(r, vRes)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Vector products`` =
//
[<Property>]
let vRes = Vector2.PerpDot(ref a, ref b)
Assert.Equal(perpDot, vRes)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Normalization =
//
[<Property>]
if not (approxEq l 0.0f) then
let norm = v.Normalized()
- Assert.ApproximatelyEqual(v.X / l, norm.X)
- Assert.ApproximatelyEqual(v.Y / l, norm.Y)
+ Assert.ApproximatelyEquivalent(v.X / l, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y / l, norm.Y)
[<Property>]
let ``Normalization of instance transforms the instance into a unit length vector with the correct components`` (a, b) =
let norm = Vector2(a, b)
norm.Normalize()
- Assert.ApproximatelyEqual(v.X / l, norm.X)
- Assert.ApproximatelyEqual(v.Y / l, norm.Y)
+ Assert.ApproximatelyEquivalent(v.X / l, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y / l, norm.Y)
[<Property>]
let ``Fast approximate normalization of instance transforms the instance into a unit length vector with the correct components`` (a, b) =
let scale = MathHelper.InverseSqrtFast(a * a + b * b)
- Assert.ApproximatelyEqual(v.X * scale, norm.X)
- Assert.ApproximatelyEqual(v.Y * scale, norm.Y)
+ Assert.ApproximatelyEquivalent(v.X * scale, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y * scale, norm.Y)
[<Property>]
let ``Normalization by reference is the same as division by magnitude`` (a : Vector2) =
let norm = a / a.Length
let vRes = Vector2.Normalize(ref a)
- Assert.ApproximatelyEqual(norm, vRes)
+ Assert.ApproximatelyEquivalent(norm, vRes)
[<Property>]
let ``Normalization is the same as division by magnitude`` (a : Vector2) =
if not (approxEq a.Length 0.0f) then
let norm = a / a.Length
- Assert.ApproximatelyEqual(norm, Vector2.Normalize(a));
+ Assert.ApproximatelyEquivalent(norm, Vector2.Normalize(a));
[<Property>]
let ``Fast approximate normalization by reference is the same as multiplication by the fast inverse square`` (a : Vector2) =
let norm = a * scale
let vRes = Vector2.NormalizeFast(ref a)
- Assert.ApproximatelyEqual(norm, vRes)
+ Assert.ApproximatelyEquivalent(norm, vRes)
[<Property>]
let ``Fast approximate normalization is the same as multiplication by the fast inverse square`` (a : Vector2) =
let norm = a * scale
- Assert.ApproximatelyEqual(norm, Vector2.NormalizeFast(a));
+ Assert.ApproximatelyEquivalent(norm, Vector2.NormalizeFast(a));
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Magnitude min and max`` =
//
[<Property>]
let v2LongerThanv1 = l2 > l1
Assert.True(v2LongerThanv1)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Component min and max`` =
//
[<Property>]
Assert.True(isComponentLargest vMax.X v1.X v2.X)
Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Transformation =
//
[<Property>]
let transformedQuat = q * vectorQuat * inverse
let transformedVector = Vector2(transformedQuat.X, transformedQuat.Y)
- Assert.ApproximatelyEqual(transformedVector, Vector2.Transform(v, q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector2.Transform(v, q))
[<Property>]
let ``Transformation by quaternion by reference is the same as multiplication by quaternion and its conjugate`` (v : Vector2, q : Quaternion) =
let transformedQuat = q * vectorQuat * inverse
let transformedVector = Vector2(transformedQuat.X, transformedQuat.Y)
- Assert.ApproximatelyEqual(transformedVector, Vector2.Transform(ref v, ref q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector2.Transform(ref v, ref q))
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Serialization =
//
[<Property>]
open OpenTK
module Vector3 =
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Constructors =
//
[<Property>]
Assert.Equal(b, v2.Y)
Assert.Equal(c, v2.Z)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Indexing =
//
[<Property>]
(fun() -> v.[4] |> ignore) |> Assert.ThrowsIndexExn
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Length =
//
[<Property>]
Assert.Equal(lsq, v.LengthSquared)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Normalization =
//
[<Property>]
if not (approxEq l 0.0f) then
let norm = v.Normalized()
- Assert.ApproximatelyEqual(v.X / l, norm.X)
- Assert.ApproximatelyEqual(v.Y / l, norm.Y)
- Assert.ApproximatelyEqual(v.Z / l, norm.Z)
+ Assert.ApproximatelyEquivalent(v.X / l, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y / l, norm.Y)
+ Assert.ApproximatelyEquivalent(v.Z / l, norm.Z)
[<Property>]
let ``Normalization of instance transforms the instance into a unit length vector with the correct components`` (a, b, c) =
let norm = Vector3(a, b, c)
norm.Normalize()
- Assert.ApproximatelyEqual(v.X / l, norm.X)
- Assert.ApproximatelyEqual(v.Y / l, norm.Y)
- Assert.ApproximatelyEqual(v.Z / l, norm.Z)
+ Assert.ApproximatelyEquivalent(v.X / l, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y / l, norm.Y)
+ Assert.ApproximatelyEquivalent(v.Z / l, norm.Z)
[<Property>]
let ``Fast approximate normalization of instance transforms the instance into a unit length vector with the correct components`` (a, b, c) =
let scale = MathHelper.InverseSqrtFast(a * a + b * b + c * c)
- Assert.ApproximatelyEqual(v.X * scale, norm.X)
- Assert.ApproximatelyEqual(v.Y * scale, norm.Y)
- Assert.ApproximatelyEqual(v.Z * scale, norm.Z)
+ Assert.ApproximatelyEquivalent(v.X * scale, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y * scale, norm.Y)
+ Assert.ApproximatelyEquivalent(v.Z * scale, norm.Z)
[<Property>]
let ``Normalization by reference is the same as division by magnitude`` (a : Vector3) =
let norm = a / a.Length
let vRes = Vector3.Normalize(ref a)
- Assert.ApproximatelyEqual(norm, vRes)
+ Assert.ApproximatelyEquivalent(norm, vRes)
[<Property>]
let ``Normalization is the same as division by magnitude`` (a : Vector3) =
if not (approxEq a.Length 0.0f) then
let norm = a / a.Length
- Assert.ApproximatelyEqual(norm, Vector3.Normalize(a));
+ Assert.ApproximatelyEquivalent(norm, Vector3.Normalize(a));
[<Property>]
let ``Fast approximate normalization by reference is the same as multiplication by the fast inverse square`` (a : Vector3) =
let norm = a * scale
let vRes = Vector3.NormalizeFast(ref a)
- Assert.ApproximatelyEqual(norm, vRes)
+ Assert.ApproximatelyEquivalent(norm, vRes)
[<Property>]
let ``Fast approximate normalization is the same as multiplication by fast inverse square`` (a : Vector3) =
let norm = a * scale
- Assert.ApproximatelyEqual(norm, Vector3.NormalizeFast(a));
+ Assert.ApproximatelyEquivalent(norm, Vector3.NormalizeFast(a));
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Addition =
//
[<Property>]
let ``Vector3 addition is the same as component addition`` (a : Vector3, b : Vector3) =
let c = a + b
- Assert.ApproximatelyEqual(a.X + b.X,c.X)
- Assert.ApproximatelyEqual(a.Y + b.Y,c.Y)
- Assert.ApproximatelyEqual(a.Z + b.Z,c.Z)
+ Assert.ApproximatelyEquivalent(a.X + b.X,c.X)
+ Assert.ApproximatelyEquivalent(a.Y + b.Y,c.Y)
+ Assert.ApproximatelyEquivalent(a.Z + b.Z,c.Z)
[<Property>]
let ``Vector3 addition is commutative`` (a : Vector3, b : Vector3) =
let c = a + b
let c2 = b + a
- Assert.ApproximatelyEqual(c, c2)
+ Assert.ApproximatelyEquivalent(c, c2)
[<Property>]
let ``Vector3 addition is associative`` (a : Vector3, b : Vector3, c : Vector3) =
let r1 = (a + b) + c
let r2 = a + (b + c)
- Assert.ApproximatelyEqual(r1, r2)
+ Assert.ApproximatelyEquivalent(r1, r2)
[<Property>]
let ``Static Vector3 addition method is the same as component addition`` (a : Vector3, b : Vector3) =
let v1 = Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z)
let sum = Vector3.Add(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector3 addition method by reference is the same as component addition`` (a : Vector3, b : Vector3) =
let v1 = Vector3(a.X + b.X, a.Y + b.Y, a.Z + b.Z)
let sum = Vector3.Add(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Subtraction =
//
[<Property>]
let v1 = Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z)
let sum = Vector3.Subtract(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector3 subtraction method by reference is the same as component addition`` (a : Vector3, b : Vector3) =
let v1 = Vector3(a.X - b.X, a.Y - b.Y, a.Z - b.Z)
let sum = Vector3.Subtract(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Multiplication =
//
[<Property>]
let v1 = Vector3(a.X * b.X, a.Y * b.Y, a.Z * b.Z)
let sum = Vector3.Multiply(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector3 multiplication method by reference is the same as component multiplication`` (a : Vector3, b : Vector3) =
let v1 = Vector3(a.X * b.X, a.Y * b.Y, a.Z * b.Z)
let sum = Vector3.Multiply(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Division =
//
[<Property>]
if not (approxEq f 0.0f) then // we don't support diving by zero.
let r = a / f
- Assert.ApproximatelyEqual(a.X / f,r.X)
- Assert.ApproximatelyEqual(a.Y / f,r.Y)
- Assert.ApproximatelyEqual(a.Z / f,r.Z)
+ Assert.ApproximatelyEquivalent(a.X / f,r.X)
+ Assert.ApproximatelyEquivalent(a.Y / f,r.Y)
+ Assert.ApproximatelyEquivalent(a.Z / f,r.Z)
[<Property>]
let ``Static Vector3-Vector3 division method is the same as component division`` (a : Vector3, b : Vector3) =
let v1 = Vector3(a.X / b.X, a.Y / b.Y, a.Z / b.Z)
let sum = Vector3.Divide(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector3-Vector3 divison method by reference is the same as component division`` (a : Vector3, b : Vector3) =
let v1 = Vector3(a.X / b.X, a.Y / b.Y, a.Z / b.Z)
let sum = Vector3.Divide(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector3-scalar division method is the same as component division`` (a : Vector3, b : float32) =
let v1 = Vector3(a.X / b, a.Y / b, a.Z / b)
let sum = Vector3.Divide(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector3-scalar divison method by reference is the same as component division`` (a : Vector3, b : float32) =
let v1 = Vector3(a.X / b, a.Y / b, a.Z / b)
let sum = Vector3.Divide(ref a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Negation =
//
[<Property>]
Assert.Equal(-y, vNeg.Y)
Assert.Equal(-z, vNeg.Z)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Equality =
//
[<Property>]
Assert.True(equality)
Assert.False(inequalityByOtherType)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Swizzling =
//
[<Property>]
Assert.Equal(zx, v.Zx);
Assert.Equal(zy, v.Zy);
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Interpolation =
//
[<Property>]
let vRes = Vector3.BaryCentric(ref a, ref b, ref c, u, v)
Assert.Equal(r, vRes)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Vector products`` =
//
[<Property>]
let vRes = Vector3.Cross(ref a, ref b)
Assert.Equal(cross, vRes)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Magnitude min and max`` =
//
[<Property>]
let v2LongerThanv1 = l2 > l1
Assert.True(v2LongerThanv1)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Component min and max`` =
//
[<Property>]
Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
Assert.True(isComponentLargest vMax.Z v1.Z v2.Z)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Clamping =
//
[<Property>]
Assert.Equal(expY, res.Y)
Assert.Equal(expZ, res.Z)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Unit vectors``=
//
[<Property>]
Assert.Equal(Vector3.One, unitOne)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Serialization =
//
[<Property>]
Assert.Equal(expectedSize, Vector3.SizeInBytes)
Assert.Equal(expectedSize, Marshal.SizeOf(Vector3()))
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Transformation =
//
[<Property>]
let transformedQuat = q * vectorQuat * inverse
let transformedVector = transformedQuat.Xyz
- Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(v, q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector3.Transform(v, q))
[<Property>]
let ``Transformation by quaternion by reference is the same as multiplication by quaternion and its conjugate`` (v : Vector3, q : Quaternion) =
let transformedQuat = q * vectorQuat * inverse
let transformedVector = transformedQuat.Xyz
- Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(ref v, ref q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector3.Transform(ref v, ref q))
[<Property>]
let ``Transformation by quaternion by multiplication using right-handed notation is the same as multiplication by quaternion and its conjugate`` (v : Vector3, q : Quaternion) =
let transformedQuat = q * vectorQuat * inverse
let transformedVector = transformedQuat.Xyz
- Assert.ApproximatelyEqual(transformedVector, q * v)
+ Assert.ApproximatelyEquivalent(transformedVector, q * v)
[<Property>]
let ``Transformation by identity quaternion does not alter vector`` (v : Vector3) =
let transformedQuat = q * vectorQuat * inverse
let transformedVector = transformedQuat.Xyz
- Assert.ApproximatelyEqual(v, transformedVector)
- Assert.ApproximatelyEqual(v, Vector3.Transform(v, q))
- Assert.ApproximatelyEqual(transformedVector, Vector3.Transform(v, q))
\ No newline at end of file
+ Assert.ApproximatelyEquivalent(v, transformedVector)
+ Assert.ApproximatelyEquivalent(v, Vector3.Transform(v, q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector3.Transform(v, q))
\ No newline at end of file
open OpenTK
module Vector4 =
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Constructors =
//
[<Property>]
Assert.Equal(z, v2.Z)
Assert.Equal(w, v2.W)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Indexing =
//
[<Property>]
(fun() -> v.[4] |> ignore) |> Assert.ThrowsIndexExn
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Length =
//
[<Property>]
Assert.Equal(lsq, v.LengthSquared)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Normalization =
//
[<Property>]
if not (approxEq l 0.0f) then
let norm = v.Normalized()
- Assert.ApproximatelyEqual(v.X / l, norm.X)
- Assert.ApproximatelyEqual(v.Y / l, norm.Y)
- Assert.ApproximatelyEqual(v.Z / l, norm.Z)
- Assert.ApproximatelyEqual(v.W / l, norm.W)
+ Assert.ApproximatelyEquivalent(v.X / l, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y / l, norm.Y)
+ Assert.ApproximatelyEquivalent(v.Z / l, norm.Z)
+ Assert.ApproximatelyEquivalent(v.W / l, norm.W)
[<Property>]
let ``Normalization of instance transforms the instance into a unit length vector with the correct components`` (x, y, z, w) =
let norm = Vector4(x, y, z, w)
norm.Normalize()
- Assert.ApproximatelyEqual(v.X / l, norm.X)
- Assert.ApproximatelyEqual(v.Y / l, norm.Y)
- Assert.ApproximatelyEqual(v.Z / l, norm.Z)
- Assert.ApproximatelyEqual(v.W / l, norm.W)
+ Assert.ApproximatelyEquivalent(v.X / l, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y / l, norm.Y)
+ Assert.ApproximatelyEquivalent(v.Z / l, norm.Z)
+ Assert.ApproximatelyEquivalent(v.W / l, norm.W)
[<Property>]
let ``Fast approximate normalization of instance transforms the instance into a unit length vector with the correct components`` (x, y, z, w) =
let scale = MathHelper.InverseSqrtFast(x * x + y * y + z * z + w * w)
- Assert.ApproximatelyEqual(v.X * scale, norm.X)
- Assert.ApproximatelyEqual(v.Y * scale, norm.Y)
- Assert.ApproximatelyEqual(v.Z * scale, norm.Z)
- Assert.ApproximatelyEqual(v.W * scale, norm.W)
+ Assert.ApproximatelyEquivalent(v.X * scale, norm.X)
+ Assert.ApproximatelyEquivalent(v.Y * scale, norm.Y)
+ Assert.ApproximatelyEquivalent(v.Z * scale, norm.Z)
+ Assert.ApproximatelyEquivalent(v.W * scale, norm.W)
[<Property>]
let ``Normalization by reference is the same as division by magnitude`` (a : Vector4) =
let norm = a / a.Length
let vRes = Vector4.Normalize(ref a)
- Assert.ApproximatelyEqual(norm, vRes)
+ Assert.ApproximatelyEquivalent(norm, vRes)
[<Property>]
let ``Normalization is the same as division by magnitude`` (a : Vector4) =
if not (approxEq a.Length 0.0f) then
let norm = a / a.Length
- Assert.ApproximatelyEqual(norm, Vector4.Normalize(a));
+ Assert.ApproximatelyEquivalent(norm, Vector4.Normalize(a));
[<Property>]
let ``Fast approximate normalization by reference is the same as multiplication by the fast inverse square`` (a : Vector4) =
let norm = a * scale
let vRes = Vector4.NormalizeFast(ref a)
- Assert.ApproximatelyEqual(norm, vRes)
+ Assert.ApproximatelyEquivalent(norm, vRes)
[<Property>]
let ``Fast approximate normalization is the same as multiplication by the fast inverse square`` (a : Vector4) =
let scale = MathHelper.InverseSqrtFast(a.X * a.X + a.Y * a.Y + a.Z * a.Z + a.W * a.W)
let norm = a * scale
- Assert.ApproximatelyEqual(norm, Vector4.NormalizeFast(a));
+ Assert.ApproximatelyEquivalent(norm, Vector4.NormalizeFast(a));
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Addition =
//
[<Property>]
let ``Vector4 addition is the same as component addition`` (a : Vector4, b : Vector4) =
let c = a + b
- Assert.ApproximatelyEqual(a.X + b.X,c.X)
- Assert.ApproximatelyEqual(a.Y + b.Y,c.Y)
- Assert.ApproximatelyEqual(a.Z + b.Z,c.Z)
- Assert.ApproximatelyEqual(a.W + b.W,c.W)
+ Assert.ApproximatelyEquivalent(a.X + b.X,c.X)
+ Assert.ApproximatelyEquivalent(a.Y + b.Y,c.Y)
+ Assert.ApproximatelyEquivalent(a.Z + b.Z,c.Z)
+ Assert.ApproximatelyEquivalent(a.W + b.W,c.W)
[<Property>]
let ``Vector4 addition is commutative`` (a : Vector4, b : Vector4) =
let c = a + b
let c2 = b + a
- Assert.ApproximatelyEqual(c, c2)
+ Assert.ApproximatelyEquivalent(c, c2)
[<Property>]
let ``Vector4 addition is associative`` (a : Vector4, b : Vector4, c : Vector4) =
let r1 = (a + b) + c
let r2 = a + (b + c)
- Assert.ApproximatelyEqual(r1, r2)
+ Assert.ApproximatelyEquivalent(r1, r2)
[<Property>]
let ``Static Vector4 addition method is the same as component addition`` (a : Vector4, b : Vector4) =
let v1 = Vector4(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W)
let sum = Vector4.Add(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector4 addition method by reference is the same as component addition`` (a : Vector4, b : Vector4) =
let v1 = Vector4(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W)
let sum = Vector4.Add(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Subtraction =
//
[<Property>]
let v1 = Vector4(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W)
let sum = Vector4.Subtract(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector4 subtraction method by reference is the same as component addition`` (a : Vector4, b : Vector4) =
let v1 = Vector4(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W)
let sum = Vector4.Subtract(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Multiplication =
//
[<Property>]
let v1 = Vector4(a.X * b.X, a.Y * b.Y, a.Z * b.Z, a.W * b.W)
let sum = Vector4.Multiply(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector4 multiplication method by reference is the same as component multiplication`` (a : Vector4, b : Vector4) =
let v1 = Vector4(a.X * b.X, a.Y * b.Y, a.Z * b.Z, a.W * b.W)
let sum = Vector4.Multiply(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Division =
//
[<Property>]
if not (approxEq f 0.0f) then // we don't support diving by zero.
let r = a / f
- Assert.ApproximatelyEqual(a.X / f, r.X)
- Assert.ApproximatelyEqual(a.Y / f, r.Y)
- Assert.ApproximatelyEqual(a.Z / f, r.Z)
- Assert.ApproximatelyEqual(a.W / f, r.W)
+ Assert.ApproximatelyEquivalent(a.X / f, r.X)
+ Assert.ApproximatelyEquivalent(a.Y / f, r.Y)
+ Assert.ApproximatelyEquivalent(a.Z / f, r.Z)
+ Assert.ApproximatelyEquivalent(a.W / f, r.W)
[<Property>]
let ``Static Vector4-Vector4 division method is the same as component division`` (a : Vector4, b : Vector4) =
let v1 = Vector4(a.X / b.X, a.Y / b.Y, a.Z / b.Z, a.W / b.W)
let sum = Vector4.Divide(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector4-Vector4 divison method by reference is the same as component division`` (a : Vector4, b : Vector4) =
let v1 = Vector4(a.X / b.X, a.Y / b.Y, a.Z / b.Z, a.W / b.W)
let sum = Vector4.Divide(ref a, ref b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector4-scalar division method is the same as component division`` (a : Vector4, b : float32) =
let v1 = Vector4(a.X / b, a.Y / b, a.Z / b, a.W / b)
let sum = Vector4.Divide(a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
[<Property>]
let ``Static Vector4-scalar divison method by reference is the same as component division`` (a : Vector4, b : float32) =
let v1 = Vector4(a.X / b, a.Y / b, a.Z / b, a.W / b)
let sum = Vector4.Divide(ref a, b)
- Assert.ApproximatelyEqual(v1, sum)
+ Assert.ApproximatelyEquivalent(v1, sum)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Negation =
//
[<Property>]
Assert.Equal(-z, vNeg.Z)
Assert.Equal(-w, vNeg.W)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Equality =
//
[<Property>]
Assert.False(inequalityByOtherType)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Swizzling =
//
[<Property>]
Assert.Equal(wy, v.Wy)
Assert.Equal(wz, v.Wz)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Interpolation =
//
[<Property>]
let vRes = Vector4.BaryCentric(ref a, ref b, ref c, u, v)
Assert.Equal(r, vRes)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Vector products`` =
//
[<Property>]
let vRes = Vector4.Dot(ref a, ref b)
Assert.Equal(dot, vRes)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Magnitude min and max`` =
//
[<Property>]
let v2LongerThanv1 = l2 > l1
Assert.True(v2LongerThanv1)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Component min and max`` =
//
[<Property>]
Assert.True(isComponentLargest vMax.W v1.W v2.W)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Clamping =
//
[<Property>]
Assert.Equal(expZ, res.Z)
Assert.Equal(expW, res.W)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module ``Unit vectors``=
//
[<Property>]
Assert.Equal(Vector4.One, unitOne)
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Serialization =
//
[<Property>]
Assert.Equal(expectedSize, Vector4.SizeInBytes)
Assert.Equal(expectedSize, Marshal.SizeOf(Vector4()))
- [<Properties(Arbitrary = [| typeof<OpenTKGen> |], MaxTest = 10000)>]
+ [<Properties(Arbitrary = [| typeof<OpenTKGen> |])>]
module Transformation =
//
[<Property>]
let transformedQuat = q * vectorQuat * inverse
let transformedVector = Vector4(transformedQuat.X, transformedQuat.Y, transformedQuat.Z, transformedQuat.W)
- Assert.ApproximatelyEqual(transformedVector, Vector4.Transform(v, q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector4.Transform(v, q))
[<Property>]
let ``Transformation by quaternion with static method by reference is the same as multiplication by quaternion and its conjugate`` (v : Vector4, q : Quaternion) =
let transformedQuat = q * vectorQuat * inverse
let transformedVector = Vector4(transformedQuat.X, transformedQuat.Y,transformedQuat.Z, transformedQuat.W)
- Assert.ApproximatelyEqual(transformedVector, Vector4.Transform(ref v, ref q))
+ Assert.ApproximatelyEquivalent(transformedVector, Vector4.Transform(ref v, ref q))
[<Property>]
let ``Transformation by quaternion by multiplication using right-handed notation is the same as multiplication by quaternion and its conjugate`` (v : Vector4, q : Quaternion) =
let transformedQuat = q * vectorQuat * inverse
let transformedVector = Vector4(transformedQuat.X, transformedQuat.Y, transformedQuat.Z, transformedQuat.W)
- Assert.ApproximatelyEqual(transformedVector, q * v)
\ No newline at end of file
+ Assert.ApproximatelyEquivalent(transformedVector, q * v)
\ No newline at end of file