From 6e0f55a584a7e2527093b4e5f9ab90b05885d6b0 Mon Sep 17 00:00:00 2001 From: varon Date: Sun, 19 Mar 2017 16:32:37 +0200 Subject: [PATCH] Add additional Vector2 tests --- tests/OpenTK.Tests/Vectors.fs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/OpenTK.Tests/Vectors.fs b/tests/OpenTK.Tests/Vectors.fs index 13e6a750..7376324f 100644 --- a/tests/OpenTK.Tests/Vectors.fs +++ b/tests/OpenTK.Tests/Vectors.fs @@ -7,6 +7,39 @@ open System open OpenTK module Vector2 = + [ |])>] + module Constructors = + // + [] + let ``Single value constructor sets all components to the same value`` (f : float32) = + let v = Vector2(f) + Assert.Equal(f,v.X) + Assert.Equal(f,v.Y) + + [] + let ``Two value constructor sets all components correctly`` (x,y) = + let v = Vector2(x,y) + Assert.Equal(x,v.X) + Assert.Equal(y,v.Y) + + [] + let ``Index operators work for the correct components`` (x,y) = + let v = Vector2(x,y) + Assert.Equal(v.[0],v.X) + Assert.Equal(v.[1],v.Y) + + [] + let ``Clamping works for each component`` (a : Vector2,b : Vector2,c : Vector2) = + let inline clamp (value : float32) minV maxV = MathHelper.Clamp(value,minV,maxV) + let r = Vector2.Clamp(a,b,c) + Assert.Equal(clamp a.X b.X c.X,r.X) + Assert.Equal(clamp a.X b.X c.X,r.Y) + + [] + let ``Length is always >= 0`` (a : Vector2) = + // + Assert.True(a.Length >= 0.0f) + [ |])>] module ``Simple Properties`` = //