NUnit Tests from Manuli and Wcdeich4 (#373)

* NUnit Tests from Manuli and Wcdeich4
This commit is contained in:
William Deich 2016-04-21 08:28:37 -07:00 committed by Harry
parent 663d8e4a6f
commit 8e3986174e
11 changed files with 1799 additions and 74 deletions

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
VisualStudioVersion = 12.0.21005.1
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "Source\OpenTK\OpenTK.csproj", "{A37A7E14-0000-0000-0000-000000000000}"
ProjectSection(ProjectDependencies) = postProject
@ -82,16 +82,73 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.API.Desktop", "Source\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.GLWidget", "Source\GLWidget\OpenTK.GLWidget.csproj", "{A625BE87-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Tests", "Source\OpenTK.Tests\OpenTK.Tests.csproj", "{930A780C-A67C-422F-9EED-DB38DAA47AB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
DebugMinimal|Any CPU = DebugMinimal|Any CPU
Documentation|Any CPU = Documentation|Any CPU
Nsis|Any CPU = Nsis|Any CPU
Release|Any CPU = Release|Any CPU
DebugMinimal|Any CPU = DebugMinimal|Any CPU
ReleaseMinimal|Any CPU = ReleaseMinimal|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{868E37B3-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A625BE88-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A625BE88-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Release|Any CPU.ActiveCfg = Release|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{31D19132-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31D19132-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31D19132-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
@ -114,22 +171,6 @@ Global
{5FDFF4B6-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{5FDFF4B6-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{5FDFF4B6-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{62C0DB35-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.Release|Any CPU.ActiveCfg = Release|Any CPU
{650C6F3D-33B5-4216-9536-956AB42C0624}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{75DC22B1-113F-4A66-96B9-2FF8208C10E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DC22B1-113F-4A66-96B9-2FF8208C10E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75DC22B1-113F-4A66-96B9-2FF8208C10E8}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
@ -141,57 +182,6 @@ Global
{75DC22B1-113F-4A66-96B9-2FF8208C10E8}.Release|Any CPU.Build.0 = Release|Any CPU
{75DC22B1-113F-4A66-96B9-2FF8208C10E8}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{75DC22B1-113F-4A66-96B9-2FF8208C10E8}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{868E37B3-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{868E37B3-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A37A7E14-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A625BE87-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A625BE87-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A625BE88-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A625BE88-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A625BE88-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A625BE88-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7A}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7B}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{ADC34399-7613-44D2-90B2-19250F06FE7B}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
@ -227,11 +217,35 @@ Global
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.Release|Any CPU.Build.0 = Release|Any CPU
{C4DDD20F-CB4E-43F4-A75C-4A3D668E1F99}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Source\Examples\OpenTK.Examples.csproj
{A625BE87-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A625BE87-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.ActiveCfg = DebugMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.DebugMinimal|Any CPU.Build.0 = DebugMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A625BE87-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{A625BE87-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.ActiveCfg = ReleaseMinimal|Any CPU
{A625BE87-0000-0000-0000-000000000000}.ReleaseMinimal|Any CPU.Build.0 = ReleaseMinimal|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.DebugMinimal|Any CPU.ActiveCfg = Debug|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.DebugMinimal|Any CPU.Build.0 = Debug|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Documentation|Any CPU.Build.0 = Debug|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Nsis|Any CPU.ActiveCfg = Release|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Nsis|Any CPU.Build.0 = Release|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.Release|Any CPU.Build.0 = Release|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.ReleaseMinimal|Any CPU.ActiveCfg = Release|Any CPU
{930A780C-A67C-422F-9EED-DB38DAA47AB0}.ReleaseMinimal|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Source\Examples\OpenTK.Examples.csproj
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,289 @@
using System;
using NUnit.Framework;
using OpenTK;
namespace NUnitTests
{
[TestFixture]
public class Matrix4Test
{
[Test]
public void Matrix4_SixteenValueConstructor()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Assert.AreEqual(0, A.M11);
Assert.AreEqual(1, A.M12);
Assert.AreEqual(2, A.M13);
Assert.AreEqual(3, A.M14);
Assert.AreEqual(4, A.M21);
Assert.AreEqual(5, A.M22);
Assert.AreEqual(6, A.M23);
Assert.AreEqual(7, A.M24);
Assert.AreEqual(8, A.M31);
Assert.AreEqual(9, A.M32);
Assert.AreEqual(10, A.M33);
Assert.AreEqual(11, A.M34);
Assert.AreEqual(12, A.M41);
Assert.AreEqual(13, A.M42);
Assert.AreEqual(14, A.M43);
Assert.AreEqual(15, A.M44);
}
[Test]
public void Matrix4_Matrix3Constructor()
{
Matrix3 B = new Matrix3( 1, 2, 3,
4, 5, 6,
7, 8, 9);
Matrix4 A = new Matrix4(B);
Assert.AreEqual(B.M11, A.M11);
Assert.AreEqual(B.M12, A.M12);
Assert.AreEqual(B.M13, A.M13);
Assert.AreEqual(B.M21, A.M21);
Assert.AreEqual(B.M22, A.M22);
Assert.AreEqual(B.M23, A.M23);
Assert.AreEqual(B.M31, A.M31);
Assert.AreEqual(B.M32, A.M32);
Assert.AreEqual(B.M33, A.M33);
}
[Test]
public void Matrix4_FourVector4Constructor()
{
Vector4 V = new Vector4(1, 2, 3, 4);
Vector4 U = new Vector4(5, 6, 7, 8);
Vector4 S = new Vector4(9, 10, 11, 12);
Vector4 T = new Vector4(13, 14, 15, 16);
Matrix4 A = new Matrix4(V, U, S, T);
Assert.AreEqual(V.X, A.M11);
Assert.AreEqual(V.Y, A.M12);
Assert.AreEqual(V.Z, A.M13);
Assert.AreEqual(V.W, A.M14);
Assert.AreEqual(U.X, A.M21);
Assert.AreEqual(U.Y, A.M22);
Assert.AreEqual(U.Z, A.M23);
Assert.AreEqual(U.W, A.M24);
Assert.AreEqual(S.X, A.M31);
Assert.AreEqual(S.Y, A.M32);
Assert.AreEqual(S.Z, A.M33);
Assert.AreEqual(S.W, A.M34);
Assert.AreEqual(T.X, A.M41);
Assert.AreEqual(T.Y, A.M42);
Assert.AreEqual(T.Z, A.M43);
Assert.AreEqual(T.W, A.M44);
}
[Test]
public void Matrix4_Equal_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Assert.IsTrue(A == B);
}
[Test]
public void Matrix4_Matrix4TimesMatrix4_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 expected = new Matrix4( 56, 62, 68, 74,
152, 174, 196, 218,
248, 286, 324, 362,
344, 398, 452, 506);
Matrix4 result = A * B;
Assert.IsTrue(expected == result);
}
[Test]
public void Matrix4_Matrix4PlusMatrix4_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 expected = new Matrix4( 0, 2, 4, 6,
8, 10, 12, 14,
16, 18, 20, 22,
24, 26, 28, 30);
Matrix4 result = A + B;
Assert.IsTrue(expected == result);
}
[Test]
public void Matrix4_Matrix4MinusMatrix4_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 expected = new Matrix4( 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0);
Matrix4 result = A - B;
Assert.IsTrue(expected == result);
}
[Test]
public void Matrix4_Index_Operator()
{
Matrix4 A = new Matrix4();
A[0, 0] = 0;
A[0, 1] = 1;
A[0, 2] = 2;
A[0, 3] = 3;
A[1, 0] = 4;
A[1, 1] = 5;
A[1, 2] = 6;
A[1, 3] = 7;
A[2, 0] = 8;
A[2, 1] = 9;
A[2, 2] = 10;
A[2, 3] = 11;
A[3, 0] = 12;
A[3, 1] = 13;
A[3, 2] = 14;
A[3, 3] = 15;
Assert.AreEqual(0, A[0, 0]);
Assert.AreEqual(1, A[0, 1]);
Assert.AreEqual(2, A[0, 2]);
Assert.AreEqual(3, A[0, 3]);
Assert.AreEqual(4, A[1, 0]);
Assert.AreEqual(5, A[1, 1]);
Assert.AreEqual(6, A[1, 2]);
Assert.AreEqual(7, A[1, 3]);
Assert.AreEqual(8, A[2, 0]);
Assert.AreEqual(9, A[2, 1]);
Assert.AreEqual(10, A[2, 2]);
Assert.AreEqual(11, A[2, 3]);
Assert.AreEqual(12, A[3, 0]);
Assert.AreEqual(13, A[3, 1]);
Assert.AreEqual(14, A[3, 2]);
Assert.AreEqual(15, A[3, 3]);
}
[Test]
public void Matrix4_Index_NegativeIndexException()
{
Matrix4 A = new Matrix4();
bool negativeIndexException = false;
try
{
A[-1, 2] = 0;
}
catch(Exception)
{
negativeIndexException = true;
}
Assert.IsTrue(negativeIndexException);
negativeIndexException = false;
try
{
A[1, -2] = 0;
}
catch (Exception)
{
negativeIndexException = true;
}
Assert.IsTrue(negativeIndexException);
negativeIndexException = false;
try
{
A[-1, -2] = 0;
}
catch (Exception)
{
negativeIndexException = true;
}
Assert.IsTrue(negativeIndexException);
}
[Test]
public void Matrix4_Index_LargeIndexException()
{
Matrix4 A = new Matrix4();
bool largeIndexException = false;
try
{
A[5, 2] = 0;
}
catch (Exception)
{
largeIndexException = true;
}
Assert.IsTrue(largeIndexException);
largeIndexException = false;
try
{
A[1, 6] = 0;
}
catch (Exception)
{
largeIndexException = true;
}
Assert.IsTrue(largeIndexException);
largeIndexException = false;
try
{
A[7, 12] = 0;
}
catch (Exception)
{
largeIndexException = true;
}
Assert.IsTrue(largeIndexException);
}
}
}

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{930A780C-A67C-422F-9EED-DB38DAA47AB0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NUnitTests</RootNamespace>
<AssemblyName>NUnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Matrix4Test.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Vector3Tests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenTK\OpenTK.csproj">
<Project>{a37a7e14-0000-0000-0000-000000000000}</Project>
<Name>OpenTK</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NUnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NUnitTests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8a03c40d-007c-4a15-ab0c-2111969ea6df")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,439 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenTK;
namespace NUnitTests
{
[TestFixture]
public class Vector3Tests
{
[Test]
public void Vector3_SingleValueConstructor()
{
Vector3 V = new Vector3(1);
Assert.AreEqual(1, V.X);
Assert.AreEqual(1, V.Y);
Assert.AreEqual(1, V.Z);
}
[Test]
public void Vector3_ThreeValueConstructor()
{
Vector3 V = new Vector3(1,2,3);
Assert.AreEqual(1, V.X);
Assert.AreEqual(2, V.Y);
Assert.AreEqual(3, V.Z);
}
[Test]
public void Vector3_Vector2Constructor()
{
Vector2 T = new Vector2(1, 2);
Vector3 V = new Vector3(T);
Assert.AreEqual(T.X, V.X);
Assert.AreEqual(T.Y, V.Y);
Assert.AreEqual(0, V.Z);
}
[Test]
public void Vector3_Vector3Constructor()
{
Vector3 U = new Vector3(1, 2, 3);
Vector3 V = new Vector3(U);
Assert.IsTrue(U == V);
}
[Test]
public void Vector3_Vector4Constructor()
{
Vector4 T = new Vector4(1, 2, 3, 0);
Vector3 V = new Vector3(T);
Assert.AreEqual(T.X, V.X);
Assert.AreEqual(T.Y, V.Y);
Assert.AreEqual(T.Z, V.Z);
}
[Test]
public void Vector3_Index_operator()
{
Vector3 V = new Vector3();
V[0] = 1; V[1] = 2; V[2] = 3;
Assert.AreEqual(1, V[0]);
Assert.AreEqual(2, V[1]);
Assert.AreEqual(3, V[2]);
}
[Test]
public void Vector3_Index_NegativeExceptin()
{
//the syntax for an expected exception changes from
//NUnit 2.6.4 / Microsoft Unit Test to NUnit 3+
//but a try-catch block is always guaranteed to work
Vector3 V = new Vector3();
bool negativeIndexExceptionFound = false;
try
{
V[-1] = 5;
}
catch (Exception)
{
negativeIndexExceptionFound = true;
}
Assert.IsTrue(negativeIndexExceptionFound);
}
[Test]
public void Vector3_Index_LargeIndexExceptin()
{
//the syntax for an expected exception changes from
//NUnit 2.6.4 / Microsoft Unit Test to NUnit 3+
//but a try-catch block is always guaranteed to work
Vector3 V = new Vector3();
bool largeIndexExceptionFound = false;
try
{
V[3] = 6;
}
catch (Exception)
{
largeIndexExceptionFound = true;
}
Assert.IsTrue(largeIndexExceptionFound);
}
[Test]
public void Vector3_Length()
{
float X = 1, Y = 2, Z = 2;
Vector3 U = new Vector3(X, Y, Z);
Assert.AreEqual((float)System.Math.Sqrt(X * X + Y * Y + Z * Z), U.Length);
}
[Test]
public void Vector3_LengthFast()
{
float X = 1, Y = 2, Z = 2;
Vector3 U = new Vector3(X, Y, Z);
Assert.AreEqual(1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z), U.LengthFast);
}
[Test]
public void Vector3_Normalized()
{
float X = 2, Y = 4, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
float length = U.Length;
Vector3 V = U.Normalized();
Assert.AreEqual(U.X / length, V.X);
Assert.AreEqual(U.Y / length, V.Y);
Assert.AreEqual(U.Z / length, V.Z);
}
[Test]
public void Vector3_NormalizeFast_Instance()
{
float X = 2, Y = 4, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V = U;
V.NormalizeFast();
float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
Assert.AreEqual(U.X * scale, V.X);
Assert.AreEqual(U.Y * scale, V.Y);
Assert.AreEqual(U.Z * scale, V.Z);
}
[Test]
public void Vector3_Add()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Add(T, U);
Assert.AreEqual(T.X + U.X, V.X);
Assert.AreEqual(T.Y + U.Y, V.Y);
Assert.AreEqual(T.Z + U.Z, V.Z);
}
[Test]
public void Vector3_Subtract()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Subtract(T, U);
Assert.AreEqual(T.X - U.X, V.X);
Assert.AreEqual(T.Y - U.Y, V.Y);
Assert.AreEqual(T.Z - U.Z, V.Z);
}
[Test]
public void Vector3_Multiply_Scalar()
{
float scalar = 5.5f;
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Multiply(U, scalar);
Assert.AreEqual(U.X * scalar, V.X);
Assert.AreEqual(U.Y * scalar, V.Y);
Assert.AreEqual(U.Z * scalar, V.Z);
}
[Test]
public void Vector3_Multiply_Componentwise()
{
Vector3 T = new Vector3(7, 8, 0.5f);
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Multiply(T, U);
Assert.AreEqual(T.X * U.X, V.X);
Assert.AreEqual(T.Y * U.Y, V.Y);
Assert.AreEqual(T.Z * U.Z, V.Z);
}
[Test]
public void Vector3_Divide_Scalar()
{
float scalar = 5.5f;
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Divide(U, scalar);
//we have to account for a small amount of round off error
//in this division test
Assert.IsTrue(Math.Abs((U.X / scalar) - V.X) < 1e-5);
Assert.IsTrue(Math.Abs((U.Y / scalar) - V.Y) < 1e-5);
Assert.IsTrue(Math.Abs((U.Z / scalar) - V.Z) < 1e-5);
}
[Test]
public void Vector3_ComponentMin()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V = Vector3.ComponentMin(T, U);
Assert.AreEqual(1, V.X);
Assert.AreEqual(3, V.Y);
Assert.AreEqual(-100, V.Z);
}
[Test]
public void Vector3_ComponentMinOut()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V;
Vector3.ComponentMin(ref T, ref U, out V);
Assert.AreEqual(1, V.X);
Assert.AreEqual(3, V.Y);
Assert.AreEqual(-100, V.Z);
}
[Test]
public void Vector3_ComponentMax()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V = Vector3.ComponentMax(T, U);
Assert.AreEqual(24, V.X);
Assert.AreEqual(55, V.Y);
Assert.AreEqual(1, V.Z);
}
[Test]
public void Vector3_ComponentMaxOut()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V;
Vector3.ComponentMax(ref T, ref U, out V);
Assert.AreEqual(24, V.X);
Assert.AreEqual(55, V.Y);
Assert.AreEqual(1, V.Z);
}
[Test]
public void Vector3_Min()
{
Vector3 T = new Vector3(1, 2, 3);
Vector3 U = new Vector3(24, 300, 88);
Vector3 result = Vector3.Min(T, U);
Assert.IsTrue(result == T);
}
[Test]
public void Vector3_Max()
{
Vector3 T = new Vector3(1, 2, 3);
Vector3 U = new Vector3(24, 300, 88);
Vector3 result = Vector3.Max(T, U);
Assert.IsTrue(result == U);
}
[Test]
public void Vector3_Clamp()
{
Vector3 V = new Vector3(-6, 302, -22);
Vector3 min = new Vector3(-5, -10, -20);
Vector3 max = new Vector3(24, 300, 55);
Vector3 result = Vector3.Clamp(V, min, max);
Assert.AreEqual(result.X, -5);
Assert.AreEqual(result.Y, 300);
Assert.AreEqual(result.Z, -20);
}
[Test]
public void Vector3_ClampOut()
{
Vector3 V = new Vector3(-6, 302, -22);
Vector3 min = new Vector3(-5, -10, -20);
Vector3 max = new Vector3(24, 300, 55);
Vector3 result;
Vector3.Clamp(ref V, ref min, ref max, out result);
Assert.AreEqual(result.X, -5);
Assert.AreEqual(result.Y, 300);
Assert.AreEqual(result.Z, -20);
}
[Test]
public void Vector3_Normalize()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V = Vector3.Normalize(U);
float length = U.Length;
Assert.IsTrue(Math.Abs((U.X / length) - V.X) < 1e-5);
Assert.IsTrue(Math.Abs((U.Y / length) - V.Y) < 1e-5);
Assert.IsTrue(Math.Abs((U.Z / length) - V.Z) < 1e-5);
}
[Test]
public void Vector3_NormalizeOut()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V;
Vector3.Normalize(ref U, out V);
float length = U.Length;
Assert.IsTrue(Math.Abs((U.X / length) - V.X) < 1e-5);
Assert.IsTrue(Math.Abs((U.Y / length) - V.Y) < 1e-5);
Assert.IsTrue(Math.Abs((U.Z / length) - V.Z) < 1e-5);
}
[Test]
public void Vector3_NormalizeFast_Static()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V = Vector3.NormalizeFast(U);
float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
Assert.AreEqual(U.X * scale, V.X);
Assert.AreEqual(U.Y * scale, V.Y);
Assert.AreEqual(U.Z * scale, V.Z);
}
[Test]
public void Vector3_NormalizeFast()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V;
Vector3.NormalizeFast(ref U, out V);
float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
Assert.AreEqual(U.X * scale, V.X);
Assert.AreEqual(U.Y * scale, V.Y);
Assert.AreEqual(U.Z * scale, V.Z);
}
[Test]
public void Vector3_Dot()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
float dot = Vector3.Dot(T, U);
float expected = T.X * U.X + T.Y * U.Y + T.Z * U.Z;
Assert.AreEqual(expected, dot);
}
[Test]
public void Vector3_Cross()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
Vector3 expected = new Vector3(-1073, 445, 439);
Vector3 result = Vector3.Cross(T, U);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_Lerp()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
float blend = 0.25f;
Vector3 expected = blend * (U - T) + T;
Vector3 result = Vector3.Lerp(T, U, blend);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_LerpOut()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
float blend = 0.25f;
Vector3 expected = blend * (U - T) + T;
Vector3 result;
Vector3.Lerp(ref T, ref U, blend, out result);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_BaryCentric()
{
Vector3 a = new Vector3(7, 8, 9);
Vector3 b = new Vector3(23, 89, -34);
Vector3 c = new Vector3(88, -42, 39);
float u = 0.25f;
float v = 0.75f;
Vector3 expected = a + u * (b - a) + v * (c - a);
Vector3 result = Vector3.BaryCentric(a, b, c, u, v);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_BaryCentricOut()
{
Vector3 a = new Vector3(7, 8, 9);
Vector3 b = new Vector3(23, 89, -34);
Vector3 c = new Vector3(88, -42, 39);
float u = 0.25f;
float v = 0.75f;
Vector3 expected = a + u * (b - a) + v * (c - a);
Vector3 result;
Vector3.BaryCentric(ref a, ref b, ref c, u, v, out result);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_Matrix3TimesVector3_operator()
{
Matrix3 A = new Matrix3();
A[0, 0] = 16; A[0, 1] = 15; A[0, 2] = 14;
A[1, 0] = 12; A[1, 1] = 11; A[1, 2] = 10;
A[2, 0] = 8; A[2, 1] = 7; A[2, 2] = 6;
Vector3 input = new Vector3(1, 5, 9);
Vector3 result = A * input;
OpenTK.Vector3 expected = new OpenTK.Vector3(217, 157, 97);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_Equal_operator()
{
Vector3 V = new Vector3(1, 2, 3);
Vector3 U = new Vector3(1, 2, 3);
Assert.IsTrue(U == V);
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net45" />
</packages>

View file

@ -0,0 +1,289 @@
using System;
using NUnit.Framework;
using OpenTK;
namespace OpenTK.Tests
{
[TestFixture]
public class Matrix4Test
{
[Test]
public void Matrix4_SixteenValueConstructor()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Assert.AreEqual(0, A.M11);
Assert.AreEqual(1, A.M12);
Assert.AreEqual(2, A.M13);
Assert.AreEqual(3, A.M14);
Assert.AreEqual(4, A.M21);
Assert.AreEqual(5, A.M22);
Assert.AreEqual(6, A.M23);
Assert.AreEqual(7, A.M24);
Assert.AreEqual(8, A.M31);
Assert.AreEqual(9, A.M32);
Assert.AreEqual(10, A.M33);
Assert.AreEqual(11, A.M34);
Assert.AreEqual(12, A.M41);
Assert.AreEqual(13, A.M42);
Assert.AreEqual(14, A.M43);
Assert.AreEqual(15, A.M44);
}
[Test]
public void Matrix4_Matrix3Constructor()
{
Matrix3 B = new Matrix3( 1, 2, 3,
4, 5, 6,
7, 8, 9);
Matrix4 A = new Matrix4(B);
Assert.AreEqual(B.M11, A.M11);
Assert.AreEqual(B.M12, A.M12);
Assert.AreEqual(B.M13, A.M13);
Assert.AreEqual(B.M21, A.M21);
Assert.AreEqual(B.M22, A.M22);
Assert.AreEqual(B.M23, A.M23);
Assert.AreEqual(B.M31, A.M31);
Assert.AreEqual(B.M32, A.M32);
Assert.AreEqual(B.M33, A.M33);
}
[Test]
public void Matrix4_FourVector4Constructor()
{
Vector4 V = new Vector4(1, 2, 3, 4);
Vector4 U = new Vector4(5, 6, 7, 8);
Vector4 S = new Vector4(9, 10, 11, 12);
Vector4 T = new Vector4(13, 14, 15, 16);
Matrix4 A = new Matrix4(V, U, S, T);
Assert.AreEqual(V.X, A.M11);
Assert.AreEqual(V.Y, A.M12);
Assert.AreEqual(V.Z, A.M13);
Assert.AreEqual(V.W, A.M14);
Assert.AreEqual(U.X, A.M21);
Assert.AreEqual(U.Y, A.M22);
Assert.AreEqual(U.Z, A.M23);
Assert.AreEqual(U.W, A.M24);
Assert.AreEqual(S.X, A.M31);
Assert.AreEqual(S.Y, A.M32);
Assert.AreEqual(S.Z, A.M33);
Assert.AreEqual(S.W, A.M34);
Assert.AreEqual(T.X, A.M41);
Assert.AreEqual(T.Y, A.M42);
Assert.AreEqual(T.Z, A.M43);
Assert.AreEqual(T.W, A.M44);
}
[Test]
public void Matrix4_Equal_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Assert.IsTrue(A == B);
}
[Test]
public void Matrix4_Matrix4TimesMatrix4_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 expected = new Matrix4( 56, 62, 68, 74,
152, 174, 196, 218,
248, 286, 324, 362,
344, 398, 452, 506);
Matrix4 result = A * B;
Assert.IsTrue(expected == result);
}
[Test]
public void Matrix4_Matrix4PlusMatrix4_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 expected = new Matrix4( 0, 2, 4, 6,
8, 10, 12, 14,
16, 18, 20, 22,
24, 26, 28, 30);
Matrix4 result = A + B;
Assert.IsTrue(expected == result);
}
[Test]
public void Matrix4_Matrix4MinusMatrix4_operator()
{
Matrix4 A = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 B = new Matrix4( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix4 expected = new Matrix4( 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0);
Matrix4 result = A - B;
Assert.IsTrue(expected == result);
}
[Test]
public void Matrix4_Index_Operator()
{
Matrix4 A = new Matrix4();
A[0, 0] = 0;
A[0, 1] = 1;
A[0, 2] = 2;
A[0, 3] = 3;
A[1, 0] = 4;
A[1, 1] = 5;
A[1, 2] = 6;
A[1, 3] = 7;
A[2, 0] = 8;
A[2, 1] = 9;
A[2, 2] = 10;
A[2, 3] = 11;
A[3, 0] = 12;
A[3, 1] = 13;
A[3, 2] = 14;
A[3, 3] = 15;
Assert.AreEqual(0, A[0, 0]);
Assert.AreEqual(1, A[0, 1]);
Assert.AreEqual(2, A[0, 2]);
Assert.AreEqual(3, A[0, 3]);
Assert.AreEqual(4, A[1, 0]);
Assert.AreEqual(5, A[1, 1]);
Assert.AreEqual(6, A[1, 2]);
Assert.AreEqual(7, A[1, 3]);
Assert.AreEqual(8, A[2, 0]);
Assert.AreEqual(9, A[2, 1]);
Assert.AreEqual(10, A[2, 2]);
Assert.AreEqual(11, A[2, 3]);
Assert.AreEqual(12, A[3, 0]);
Assert.AreEqual(13, A[3, 1]);
Assert.AreEqual(14, A[3, 2]);
Assert.AreEqual(15, A[3, 3]);
}
[Test]
public void Matrix4_Index_NegativeIndexException()
{
Matrix4 A = new Matrix4();
bool negativeIndexException = false;
try
{
A[-1, 2] = 0;
}
catch(Exception)
{
negativeIndexException = true;
}
Assert.IsTrue(negativeIndexException);
negativeIndexException = false;
try
{
A[1, -2] = 0;
}
catch (Exception)
{
negativeIndexException = true;
}
Assert.IsTrue(negativeIndexException);
negativeIndexException = false;
try
{
A[-1, -2] = 0;
}
catch (Exception)
{
negativeIndexException = true;
}
Assert.IsTrue(negativeIndexException);
}
[Test]
public void Matrix4_Index_LargeIndexException()
{
Matrix4 A = new Matrix4();
bool largeIndexException = false;
try
{
A[5, 2] = 0;
}
catch (Exception)
{
largeIndexException = true;
}
Assert.IsTrue(largeIndexException);
largeIndexException = false;
try
{
A[1, 6] = 0;
}
catch (Exception)
{
largeIndexException = true;
}
Assert.IsTrue(largeIndexException);
largeIndexException = false;
try
{
A[7, 12] = 0;
}
catch (Exception)
{
largeIndexException = true;
}
Assert.IsTrue(largeIndexException);
}
}
}

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{930A780C-A67C-422F-9EED-DB38DAA47AB0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenTK.Tests</RootNamespace>
<AssemblyName>OpenTK.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Matrix4Test.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Vector3Tests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenTK\OpenTK.csproj">
<Project>{a37a7e14-0000-0000-0000-000000000000}</Project>
<Name>OpenTK</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenTK.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenTK.Tests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8a03c40d-007c-4a15-ab0c-2111969ea6df")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,439 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenTK;
namespace OpenTK.Tests
{
[TestFixture]
public class Vector3Tests
{
[Test]
public void Vector3_SingleValueConstructor()
{
Vector3 V = new Vector3(1);
Assert.AreEqual(1, V.X);
Assert.AreEqual(1, V.Y);
Assert.AreEqual(1, V.Z);
}
[Test]
public void Vector3_ThreeValueConstructor()
{
Vector3 V = new Vector3(1,2,3);
Assert.AreEqual(1, V.X);
Assert.AreEqual(2, V.Y);
Assert.AreEqual(3, V.Z);
}
[Test]
public void Vector3_Vector2Constructor()
{
Vector2 T = new Vector2(1, 2);
Vector3 V = new Vector3(T);
Assert.AreEqual(T.X, V.X);
Assert.AreEqual(T.Y, V.Y);
Assert.AreEqual(0, V.Z);
}
[Test]
public void Vector3_Vector3Constructor()
{
Vector3 U = new Vector3(1, 2, 3);
Vector3 V = new Vector3(U);
Assert.IsTrue(U == V);
}
[Test]
public void Vector3_Vector4Constructor()
{
Vector4 T = new Vector4(1, 2, 3, 0);
Vector3 V = new Vector3(T);
Assert.AreEqual(T.X, V.X);
Assert.AreEqual(T.Y, V.Y);
Assert.AreEqual(T.Z, V.Z);
}
[Test]
public void Vector3_Index_operator()
{
Vector3 V = new Vector3();
V[0] = 1; V[1] = 2; V[2] = 3;
Assert.AreEqual(1, V[0]);
Assert.AreEqual(2, V[1]);
Assert.AreEqual(3, V[2]);
}
[Test]
public void Vector3_Index_NegativeExceptin()
{
//the syntax for an expected exception changes from
//NUnit 2.6.4 / Microsoft Unit Test to NUnit 3+
//but a try-catch block is always guaranteed to work
Vector3 V = new Vector3();
bool negativeIndexExceptionFound = false;
try
{
V[-1] = 5;
}
catch (Exception)
{
negativeIndexExceptionFound = true;
}
Assert.IsTrue(negativeIndexExceptionFound);
}
[Test]
public void Vector3_Index_LargeIndexExceptin()
{
//the syntax for an expected exception changes from
//NUnit 2.6.4 / Microsoft Unit Test to NUnit 3+
//but a try-catch block is always guaranteed to work
Vector3 V = new Vector3();
bool largeIndexExceptionFound = false;
try
{
V[3] = 6;
}
catch (Exception)
{
largeIndexExceptionFound = true;
}
Assert.IsTrue(largeIndexExceptionFound);
}
[Test]
public void Vector3_Length()
{
float X = 1, Y = 2, Z = 2;
Vector3 U = new Vector3(X, Y, Z);
Assert.AreEqual((float)System.Math.Sqrt(X * X + Y * Y + Z * Z), U.Length);
}
[Test]
public void Vector3_LengthFast()
{
float X = 1, Y = 2, Z = 2;
Vector3 U = new Vector3(X, Y, Z);
Assert.AreEqual(1.0f / MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z), U.LengthFast);
}
[Test]
public void Vector3_Normalized()
{
float X = 2, Y = 4, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
float length = U.Length;
Vector3 V = U.Normalized();
Assert.AreEqual(U.X / length, V.X);
Assert.AreEqual(U.Y / length, V.Y);
Assert.AreEqual(U.Z / length, V.Z);
}
[Test]
public void Vector3_NormalizeFast_Instance()
{
float X = 2, Y = 4, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V = U;
V.NormalizeFast();
float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
Assert.AreEqual(U.X * scale, V.X);
Assert.AreEqual(U.Y * scale, V.Y);
Assert.AreEqual(U.Z * scale, V.Z);
}
[Test]
public void Vector3_Add()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Add(T, U);
Assert.AreEqual(T.X + U.X, V.X);
Assert.AreEqual(T.Y + U.Y, V.Y);
Assert.AreEqual(T.Z + U.Z, V.Z);
}
[Test]
public void Vector3_Subtract()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Subtract(T, U);
Assert.AreEqual(T.X - U.X, V.X);
Assert.AreEqual(T.Y - U.Y, V.Y);
Assert.AreEqual(T.Z - U.Z, V.Z);
}
[Test]
public void Vector3_Multiply_Scalar()
{
float scalar = 5.5f;
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Multiply(U, scalar);
Assert.AreEqual(U.X * scalar, V.X);
Assert.AreEqual(U.Y * scalar, V.Y);
Assert.AreEqual(U.Z * scalar, V.Z);
}
[Test]
public void Vector3_Multiply_Componentwise()
{
Vector3 T = new Vector3(7, 8, 0.5f);
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Multiply(T, U);
Assert.AreEqual(T.X * U.X, V.X);
Assert.AreEqual(T.Y * U.Y, V.Y);
Assert.AreEqual(T.Z * U.Z, V.Z);
}
[Test]
public void Vector3_Divide_Scalar()
{
float scalar = 5.5f;
Vector3 U = new Vector3(23, 89, -34);
Vector3 V = Vector3.Divide(U, scalar);
//we have to account for a small amount of round off error
//in this division test
Assert.IsTrue(Math.Abs((U.X / scalar) - V.X) < 1e-5);
Assert.IsTrue(Math.Abs((U.Y / scalar) - V.Y) < 1e-5);
Assert.IsTrue(Math.Abs((U.Z / scalar) - V.Z) < 1e-5);
}
[Test]
public void Vector3_ComponentMin()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V = Vector3.ComponentMin(T, U);
Assert.AreEqual(1, V.X);
Assert.AreEqual(3, V.Y);
Assert.AreEqual(-100, V.Z);
}
[Test]
public void Vector3_ComponentMinOut()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V;
Vector3.ComponentMin(ref T, ref U, out V);
Assert.AreEqual(1, V.X);
Assert.AreEqual(3, V.Y);
Assert.AreEqual(-100, V.Z);
}
[Test]
public void Vector3_ComponentMax()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V = Vector3.ComponentMax(T, U);
Assert.AreEqual(24, V.X);
Assert.AreEqual(55, V.Y);
Assert.AreEqual(1, V.Z);
}
[Test]
public void Vector3_ComponentMaxOut()
{
Vector3 T = new Vector3(1, 55, -100);
Vector3 U = new Vector3(24, 3, 1);
Vector3 V;
Vector3.ComponentMax(ref T, ref U, out V);
Assert.AreEqual(24, V.X);
Assert.AreEqual(55, V.Y);
Assert.AreEqual(1, V.Z);
}
[Test]
public void Vector3_Min()
{
Vector3 T = new Vector3(1, 2, 3);
Vector3 U = new Vector3(24, 300, 88);
Vector3 result = Vector3.Min(T, U);
Assert.IsTrue(result == T);
}
[Test]
public void Vector3_Max()
{
Vector3 T = new Vector3(1, 2, 3);
Vector3 U = new Vector3(24, 300, 88);
Vector3 result = Vector3.Max(T, U);
Assert.IsTrue(result == U);
}
[Test]
public void Vector3_Clamp()
{
Vector3 V = new Vector3(-6, 302, -22);
Vector3 min = new Vector3(-5, -10, -20);
Vector3 max = new Vector3(24, 300, 55);
Vector3 result = Vector3.Clamp(V, min, max);
Assert.AreEqual(result.X, -5);
Assert.AreEqual(result.Y, 300);
Assert.AreEqual(result.Z, -20);
}
[Test]
public void Vector3_ClampOut()
{
Vector3 V = new Vector3(-6, 302, -22);
Vector3 min = new Vector3(-5, -10, -20);
Vector3 max = new Vector3(24, 300, 55);
Vector3 result;
Vector3.Clamp(ref V, ref min, ref max, out result);
Assert.AreEqual(result.X, -5);
Assert.AreEqual(result.Y, 300);
Assert.AreEqual(result.Z, -20);
}
[Test]
public void Vector3_Normalize()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V = Vector3.Normalize(U);
float length = U.Length;
Assert.IsTrue(Math.Abs((U.X / length) - V.X) < 1e-5);
Assert.IsTrue(Math.Abs((U.Y / length) - V.Y) < 1e-5);
Assert.IsTrue(Math.Abs((U.Z / length) - V.Z) < 1e-5);
}
[Test]
public void Vector3_NormalizeOut()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V;
Vector3.Normalize(ref U, out V);
float length = U.Length;
Assert.IsTrue(Math.Abs((U.X / length) - V.X) < 1e-5);
Assert.IsTrue(Math.Abs((U.Y / length) - V.Y) < 1e-5);
Assert.IsTrue(Math.Abs((U.Z / length) - V.Z) < 1e-5);
}
[Test]
public void Vector3_NormalizeFast_Static()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V = Vector3.NormalizeFast(U);
float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
Assert.AreEqual(U.X * scale, V.X);
Assert.AreEqual(U.Y * scale, V.Y);
Assert.AreEqual(U.Z * scale, V.Z);
}
[Test]
public void Vector3_NormalizeFast()
{
float X = 64, Y = 144, Z = 16;
Vector3 U = new Vector3(X, Y, Z);
Vector3 V;
Vector3.NormalizeFast(ref U, out V);
float scale = MathHelper.InverseSqrtFast(X * X + Y * Y + Z * Z);
Assert.AreEqual(U.X * scale, V.X);
Assert.AreEqual(U.Y * scale, V.Y);
Assert.AreEqual(U.Z * scale, V.Z);
}
[Test]
public void Vector3_Dot()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
float dot = Vector3.Dot(T, U);
float expected = T.X * U.X + T.Y * U.Y + T.Z * U.Z;
Assert.AreEqual(expected, dot);
}
[Test]
public void Vector3_Cross()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
Vector3 expected = new Vector3(-1073, 445, 439);
Vector3 result = Vector3.Cross(T, U);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_Lerp()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
float blend = 0.25f;
Vector3 expected = blend * (U - T) + T;
Vector3 result = Vector3.Lerp(T, U, blend);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_LerpOut()
{
Vector3 T = new Vector3(7, 8, 9);
Vector3 U = new Vector3(23, 89, -34);
float blend = 0.25f;
Vector3 expected = blend * (U - T) + T;
Vector3 result;
Vector3.Lerp(ref T, ref U, blend, out result);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_BaryCentric()
{
Vector3 a = new Vector3(7, 8, 9);
Vector3 b = new Vector3(23, 89, -34);
Vector3 c = new Vector3(88, -42, 39);
float u = 0.25f;
float v = 0.75f;
Vector3 expected = a + u * (b - a) + v * (c - a);
Vector3 result = Vector3.BaryCentric(a, b, c, u, v);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_BaryCentricOut()
{
Vector3 a = new Vector3(7, 8, 9);
Vector3 b = new Vector3(23, 89, -34);
Vector3 c = new Vector3(88, -42, 39);
float u = 0.25f;
float v = 0.75f;
Vector3 expected = a + u * (b - a) + v * (c - a);
Vector3 result;
Vector3.BaryCentric(ref a, ref b, ref c, u, v, out result);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_Matrix3TimesVector3_operator()
{
Matrix3 A = new Matrix3();
A[0, 0] = 16; A[0, 1] = 15; A[0, 2] = 14;
A[1, 0] = 12; A[1, 1] = 11; A[1, 2] = 10;
A[2, 0] = 8; A[2, 1] = 7; A[2, 2] = 6;
Vector3 input = new Vector3(1, 5, 9);
Vector3 result = A * input;
OpenTK.Vector3 expected = new OpenTK.Vector3(217, 157, 97);
Assert.IsTrue(expected == result);
}
[Test]
public void Vector3_Equal_operator()
{
Vector3 V = new Vector3(1, 2, 3);
Vector3 U = new Vector3(1, 2, 3);
Assert.IsTrue(U == V);
}
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net45" />
</packages>