Restructured Quaternion tests
This commit is contained in:
parent
5aed63e396
commit
a875bfe6b9
1 changed files with 124 additions and 93 deletions
|
@ -5,6 +5,11 @@ using OpenTK.Tests.Math.DataProviders;
|
|||
namespace OpenTK.Tests.Math
|
||||
{
|
||||
public class Quaternion_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains all tests which cover the ctor of Quaternion.
|
||||
/// </summary>
|
||||
public class Constructor_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a single given value (either pitch, yaw or roll) get converted into correct x,y,z value of quaternion.
|
||||
|
@ -14,7 +19,8 @@ namespace OpenTK.Tests.Math
|
|||
/// <param name="testName">Taken from nUnit test data. Don't know how to name data driven tests for xUnit which actually works.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(QuaternionTestDataGenerator.SingleAxisTestCases), MemberType = typeof(QuaternionTestDataGenerator))]
|
||||
public void CtorEulerAnglesFloat_SingleEulerAngleSet_RotateCorrectAxis(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
public void SingleAxisAsEulerAnglesInFloatsIsConvertedToCorrectValueInQuaternion
|
||||
(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
{
|
||||
//Arrange + Act: Create Quaternion with "pitch/yaw/roll"
|
||||
var cut = new Quaternion(eulerValues.X, eulerValues.Y, eulerValues.Z);
|
||||
|
@ -33,7 +39,8 @@ namespace OpenTK.Tests.Math
|
|||
/// <param name="testName">Taken from nUnit test data. Don't know how to name data driven tests for xUnit which actually works.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(QuaternionTestDataGenerator.SingleAxisTestCases), MemberType = typeof(QuaternionTestDataGenerator))]
|
||||
public void CtorEulerAnglesVector3_SingleEulerAngleSet_RotateCorrectAxis(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
public void SingleAxisAsEulerAnglesInVector3IsConvertedToCorrectValueInQuaternion
|
||||
(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
{
|
||||
//Arrange + Act: Create Quaternion with "pitch/yaw/roll"
|
||||
var cut = new Quaternion(eulerValues);
|
||||
|
@ -44,6 +51,14 @@ namespace OpenTK.Tests.Math
|
|||
Assert.True(QuaternionTestHelper.VerifyEqualSingleDirection(resultXYZ, expectedResult));
|
||||
}
|
||||
|
||||
//TODO: Make also checks with ccw rotation angle and correct applied rotation order of multiple axis
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains all tests for FromEulerAngles
|
||||
/// </summary>
|
||||
public class FromEulerAngles_Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a single given value (either pitch, yaw or roll) get converted into correct x,y,z value of quaternion.
|
||||
/// </summary>
|
||||
|
@ -52,7 +67,8 @@ namespace OpenTK.Tests.Math
|
|||
/// <param name="testName">Taken from nUnit test data. Don't know how to name data driven tests for xUnit which actually works.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(QuaternionTestDataGenerator.SingleAxisTestCases), MemberType = typeof(QuaternionTestDataGenerator))]
|
||||
public void FromEulerAnglesFloat_SingleEulerAngleSet_RotateCorrectAxis(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
public void SingleAxisAsEulerAnglesInFloatsIsConvertedToCorrectValueInQuaternion
|
||||
(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
{
|
||||
//Arrange + Act: Create Quaternion with "pitch/yaw/roll"
|
||||
var cut = Quaternion.FromEulerAngles(eulerValues.X, eulerValues.Y, eulerValues.Z);
|
||||
|
@ -71,7 +87,8 @@ namespace OpenTK.Tests.Math
|
|||
/// <param name="testName">Taken from nUnit test data. Don't know how to name data driven tests for xUnit which actually works.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(QuaternionTestDataGenerator.SingleAxisTestCases), MemberType = typeof(QuaternionTestDataGenerator))]
|
||||
public void FromEulerAnglesVector3_SingleEulerAngleSet_RotateCorrectAxis(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
public void SingleAxisAsEulerAnglesInVector3IsConvertedToCorrectValueInQuaternion
|
||||
(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
{
|
||||
//Arrange + Act: Create Quaternion with "pitch/yaw/roll"
|
||||
var cut = Quaternion.FromEulerAngles(eulerValues);
|
||||
|
@ -90,7 +107,8 @@ namespace OpenTK.Tests.Math
|
|||
/// <param name="testName">Taken from nUnit test data. Don't know how to name data driven tests for xUnit which actually works.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(QuaternionTestDataGenerator.SingleAxisTestCases), MemberType = typeof(QuaternionTestDataGenerator))]
|
||||
public void FromEulerAnglesOut_SingleEulerAngleSet_RotateCorrectAxis(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
public void SingleAxisAsEulerAnglesInVector3IsConvertedToCorrectValueInQuaternionAsOutParam
|
||||
(Vector3 eulerValues, Vector3 expectedResult, string testName)
|
||||
{
|
||||
//Arrange + Act: Create Quaternion with "pitch/yaw/roll"
|
||||
var cut = Quaternion.Identity;
|
||||
|
@ -102,6 +120,15 @@ namespace OpenTK.Tests.Math
|
|||
Assert.True(QuaternionTestHelper.VerifyEqualSingleDirection(resultXYZ, expectedResult));
|
||||
}
|
||||
|
||||
//TODO: Make also checks with ccw rotation angle and correct applied rotation order of multiple axis
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Contains all test for ToAxisAngle
|
||||
/// </summary>
|
||||
public class ToAxisAngle
|
||||
{
|
||||
/// <summary>
|
||||
/// Check if a quaternion returns a a rotation about the correct coordinate axis
|
||||
/// </summary>
|
||||
|
@ -110,7 +137,7 @@ namespace OpenTK.Tests.Math
|
|||
/// <param name="testName">Taken from nUnit test data. Don't know how to name data driven tests for xUnit which actually works.</param>
|
||||
[Theory]
|
||||
[MemberData(nameof(QuaternionTestDataGenerator.ToAxisAngleTestCases), MemberType = typeof(QuaternionTestDataGenerator))]
|
||||
public void ToAxisAngle_SingleAxisSetAndAngleIgnored_RotateCorrectAxis(Quaternion cut, Vector3 expectedResult, string testName)
|
||||
public void PreparedSingleRotationAxisQuaternionConvertsToCorrectAxisAngleRepresentation(Quaternion cut, Vector3 expectedResult, string testName)
|
||||
{
|
||||
//Arrange + Act: Create Quaternion with rotation about X/Y/Z axis
|
||||
Vector3 resultXYZ;
|
||||
|
@ -121,7 +148,11 @@ namespace OpenTK.Tests.Math
|
|||
Assert.True(QuaternionTestHelper.VerifyEqualSingleDirection(resultXYZ, expectedResult));
|
||||
}
|
||||
|
||||
//TODO: Make also checks with rotation angle
|
||||
//TODO: Make also checks with ccw rotation angle and correct applied rotation order of multiple axis
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue