Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ obj
*.pidb
*.userprefs
*.suo
TestResults/
68 changes: 68 additions & 0 deletions GameMathTests/GameMathTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8C447CE8-3234-4F00-A88F-555656FB231E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GameMathTests</RootNamespace>
<AssemblyName>GameMathTests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</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="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="QuaternionTests.cs" />
<Compile Include="Vector4Tests.cs" />
<Compile Include="Vector3Tests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Vector2Tests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mono.GameMath\Mono.GameMath.csproj">
<Project>{DAC0541A-CB1C-44CA-BE7C-BF6CD5A8A9EE}</Project>
<Name>Mono.GameMath</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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>
35 changes: 35 additions & 0 deletions GameMathTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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("GameMathTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("GameMathTests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[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("a35f57db-3249-42e7-a944-b5166b4392cf")]

// 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.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
63 changes: 63 additions & 0 deletions GameMathTests/QuaternionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.GameMath;

namespace GameMathTests
{
[TestClass]
public class QuaternionTests
{
public Quaternion Zero { get { return new Quaternion(); } }
public Quaternion UnitX { get { return new Quaternion(1, 0, 0, 0); } }
public Quaternion UnitY { get { return new Quaternion(0, 1, 0, 0); } }
public Quaternion UnitZ { get { return new Quaternion(0, 0, 1, 0); } }
public Quaternion UnitW { get { return new Quaternion(0, 0, 0, 1); } }


[TestMethod]
public void NaNEquality()
{
Quaternion nanQuat = new Quaternion(float.NaN, float.NaN, float.NaN, float.NaN);
Assert.IsFalse(nanQuat == nanQuat);
Assert.IsTrue(nanQuat != nanQuat);
Assert.IsTrue(nanQuat.Equals(nanQuat));
}

[TestMethod]
public void SimpleEquality()
{
Assert.IsTrue(Zero == Zero);
Assert.IsFalse(Zero != Zero);

Assert.IsFalse(Zero == UnitX);
Assert.IsFalse(Zero == UnitY);
Assert.IsFalse(Zero == UnitZ);
Assert.IsFalse(Zero == UnitW);

Assert.IsTrue(Zero.Equals(Zero));
Assert.IsTrue(UnitX.Equals(UnitX));
Assert.IsTrue(UnitY.Equals(UnitY));
Assert.IsTrue(UnitZ.Equals(UnitZ));
Assert.IsTrue(UnitW.Equals(UnitW));

Assert.IsFalse(Zero.Equals(UnitX));
Assert.IsFalse(Zero.Equals(UnitY));
Assert.IsFalse(Zero.Equals(UnitZ));
Assert.IsFalse(Zero.Equals(UnitW));
}

[TestMethod]
public void GoodHashCode()
{
Assert.IsTrue(UnitX.GetHashCode() != UnitY.GetHashCode());

Assert.IsTrue(Zero.GetHashCode() != UnitX.GetHashCode());
Assert.IsTrue(Zero.GetHashCode() != UnitY.GetHashCode());
Assert.IsTrue(Zero.GetHashCode() != UnitZ.GetHashCode());
Assert.IsTrue(Zero.GetHashCode() != UnitW.GetHashCode());
}
}
}
47 changes: 47 additions & 0 deletions GameMathTests/Vector2Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.GameMath;

namespace GameMathTests
{
[TestClass]
public class Vector2Tests
{
[TestMethod]
public void NaNEquality()
{
Vector2 nanVec = new Vector2(float.NaN, float.NaN);
Assert.IsFalse(nanVec == nanVec);
Assert.IsTrue(nanVec != nanVec);
Assert.IsTrue(nanVec.Equals(nanVec));
}

[TestMethod]
public void SimpleEquality()
{
Assert.IsTrue(Vector2.Zero == Vector2.Zero);
Assert.IsFalse(Vector2.Zero != Vector2.Zero);

Assert.IsFalse(Vector2.Zero == Vector2.UnitX);
Assert.IsFalse(Vector2.Zero == Vector2.UnitY);

Assert.IsTrue(Vector2.Zero.Equals(Vector2.Zero));
Assert.IsTrue(Vector2.UnitX.Equals(Vector2.UnitX));
Assert.IsTrue(Vector2.UnitY.Equals(Vector2.UnitY));

Assert.IsFalse(Vector2.Zero.Equals(Vector2.UnitX));
Assert.IsFalse(Vector2.Zero.Equals(Vector2.UnitY));
}

[TestMethod]
public void GoodHashCode()
{
Assert.IsTrue(Vector2.UnitX.GetHashCode() != Vector2.UnitY.GetHashCode());
Assert.IsTrue(Vector2.Zero.GetHashCode() != Vector2.UnitX.GetHashCode());
Assert.IsTrue(Vector2.Zero.GetHashCode() != Vector2.UnitY.GetHashCode());
}
}
}
52 changes: 52 additions & 0 deletions GameMathTests/Vector3Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.GameMath;

namespace GameMathTests
{
[TestClass]
public class Vector3Tests
{
[TestMethod]
public void NaNEquality()
{
Vector3 nanVec = new Vector3(float.NaN, float.NaN, float.NaN);
Assert.IsFalse(nanVec == nanVec);
Assert.IsTrue(nanVec != nanVec);
Assert.IsTrue(nanVec.Equals(nanVec));
}

[TestMethod]
public void SimpleEquality()
{
Assert.IsTrue(Vector3.Zero == Vector3.Zero);
Assert.IsFalse(Vector3.Zero != Vector3.Zero);

Assert.IsFalse(Vector3.Zero == Vector3.UnitX);
Assert.IsFalse(Vector3.Zero == Vector3.UnitY);
Assert.IsFalse(Vector3.Zero == Vector3.UnitZ);

Assert.IsTrue(Vector3.Zero.Equals(Vector3.Zero));
Assert.IsTrue(Vector3.UnitX.Equals(Vector3.UnitX));
Assert.IsTrue(Vector3.UnitY.Equals(Vector3.UnitY));
Assert.IsTrue(Vector3.UnitZ.Equals(Vector3.UnitZ));

Assert.IsFalse(Vector3.Zero.Equals(Vector3.UnitX));
Assert.IsFalse(Vector3.Zero.Equals(Vector3.UnitY));
Assert.IsFalse(Vector3.Zero.Equals(Vector3.UnitZ));
}

[TestMethod]
public void GoodHashCode()
{
Assert.IsTrue(Vector3.UnitX.GetHashCode() != Vector3.UnitY.GetHashCode());

Assert.IsTrue(Vector3.Zero.GetHashCode() != Vector3.UnitX.GetHashCode());
Assert.IsTrue(Vector3.Zero.GetHashCode() != Vector3.UnitY.GetHashCode());
Assert.IsTrue(Vector3.Zero.GetHashCode() != Vector3.UnitZ.GetHashCode());
}
}
}
56 changes: 56 additions & 0 deletions GameMathTests/Vector4Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.GameMath;

namespace GameMathTests
{
[TestClass]
public class Vector4Tests
{
[TestMethod]
public void NaNEquality()
{
Vector4 nanVec = new Vector4(float.NaN, float.NaN, float.NaN, float.NaN);
Assert.IsFalse(nanVec == nanVec);
Assert.IsTrue(nanVec != nanVec);
Assert.IsTrue(nanVec.Equals(nanVec));
}

[TestMethod]
public void SimpleEquality()
{
Assert.IsTrue(Vector4.Zero == Vector4.Zero);
Assert.IsFalse(Vector4.Zero != Vector4.Zero);

Assert.IsFalse(Vector4.Zero == Vector4.UnitX);
Assert.IsFalse(Vector4.Zero == Vector4.UnitY);
Assert.IsFalse(Vector4.Zero == Vector4.UnitZ);
Assert.IsFalse(Vector4.Zero == Vector4.UnitW);

Assert.IsTrue(Vector4.Zero.Equals(Vector4.Zero));
Assert.IsTrue(Vector4.UnitX.Equals(Vector4.UnitX));
Assert.IsTrue(Vector4.UnitY.Equals(Vector4.UnitY));
Assert.IsTrue(Vector4.UnitZ.Equals(Vector4.UnitZ));
Assert.IsTrue(Vector4.UnitW.Equals(Vector4.UnitW));

Assert.IsFalse(Vector4.Zero.Equals(Vector4.UnitX));
Assert.IsFalse(Vector4.Zero.Equals(Vector4.UnitY));
Assert.IsFalse(Vector4.Zero.Equals(Vector4.UnitZ));
Assert.IsFalse(Vector4.Zero.Equals(Vector4.UnitW));
}

[TestMethod]
public void GoodHashCode()
{
Assert.IsTrue(Vector4.UnitX.GetHashCode() != Vector4.UnitY.GetHashCode());

Assert.IsTrue(Vector4.Zero.GetHashCode() != Vector4.UnitX.GetHashCode());
Assert.IsTrue(Vector4.Zero.GetHashCode() != Vector4.UnitY.GetHashCode());
Assert.IsTrue(Vector4.Zero.GetHashCode() != Vector4.UnitZ.GetHashCode());
Assert.IsTrue(Vector4.Zero.GetHashCode() != Vector4.UnitW.GetHashCode());
}
}
}
Loading