Translated tests for Math/Similar
This commit is contained in:
parent
51421188c7
commit
009b15e415
@ -16,6 +16,7 @@ add_executable(Tests
|
|||||||
Math__Lerp.cpp
|
Math__Lerp.cpp
|
||||||
Math__Max.cpp
|
Math__Max.cpp
|
||||||
Math__Min.cpp
|
Math__Min.cpp
|
||||||
|
Math__Similar.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(Tests Eule)
|
target_link_libraries(Tests Eule)
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
#include "CppUnitTest.h"
|
|
||||||
#include "../Eule/Math.h"
|
|
||||||
|
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
||||||
using namespace Eule;
|
|
||||||
|
|
||||||
/** Equivalence classes:
|
|
||||||
* -- a < b
|
|
||||||
* -- a > b
|
|
||||||
* -- a == b
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace _Math
|
|
||||||
{
|
|
||||||
TEST_CLASS(_Max)
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// a < b
|
|
||||||
TEST_METHOD(a_lt_b)
|
|
||||||
{
|
|
||||||
Assert::AreEqual(12.0, Math::Max(4.0, 12.0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a > b
|
|
||||||
TEST_METHOD(a_gt_b)
|
|
||||||
{
|
|
||||||
Assert::AreEqual(12.0, Math::Max(12.0, 4.0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a == b
|
|
||||||
TEST_METHOD(a_eq_b)
|
|
||||||
{
|
|
||||||
Assert::AreEqual(9.0, Math::Max(9.0, 9.0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
#include "CppUnitTest.h"
|
|
||||||
#include "../Eule/Math.h"
|
|
||||||
|
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
||||||
using namespace Eule;
|
|
||||||
|
|
||||||
/** Equivalence classes:
|
|
||||||
* -- min < v < max
|
|
||||||
* -- v < min < max
|
|
||||||
* -- min < max < v
|
|
||||||
* -- v == min < max
|
|
||||||
* -- min < v == max
|
|
||||||
* -- v < max == min
|
|
||||||
* -- max == min < v
|
|
||||||
* -- max == min == v
|
|
||||||
* -- max < v < min
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Equivalence classes:
|
|
||||||
* -- a < b
|
|
||||||
* -- a > b
|
|
||||||
* -- a == b
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace _Math
|
|
||||||
{
|
|
||||||
TEST_CLASS(_Min)
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// a < b
|
|
||||||
TEST_METHOD(a_lt_b)
|
|
||||||
{
|
|
||||||
Assert::AreEqual(4.0, Math::Min(4.0, 9.0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a > b
|
|
||||||
TEST_METHOD(a_gt_b)
|
|
||||||
{
|
|
||||||
Assert::AreEqual(4.0, Math::Min(9.0, 4.0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a == b
|
|
||||||
TEST_METHOD(a_eq_b)
|
|
||||||
{
|
|
||||||
Assert::AreEqual(9.0, Math::Min(9.0, 9.0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
53
Test/Math__Similar.cpp
Normal file
53
Test/Math__Similar.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include "Catch2.h"
|
||||||
|
#include <Eule/Math.h>
|
||||||
|
|
||||||
|
using namespace Eule;
|
||||||
|
|
||||||
|
// Checks that the similar function works with an exact comparison -> true
|
||||||
|
TEST_CASE(__FILE__"/Exact_Comparison_True", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE(Math::Similar(100, 100, 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that the similar function works with an exact comparison -> false
|
||||||
|
TEST_CASE(__FILE__"/Exact_Comparison_False", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE_FALSE(Math::Similar(100, 100.001, 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that the similar function works with an exact comparison -> false
|
||||||
|
TEST_CASE(__FILE__"/Exact_Comparison_False2", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE_FALSE(Math::Similar(100, 99.999, 0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that the similar function works with a loose comparison -> true
|
||||||
|
TEST_CASE(__FILE__"/Loose_Comparison_True", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE(Math::Similar(100, 100.001, 0.01));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that the similar function works with a loose comparison -> true
|
||||||
|
TEST_CASE(__FILE__"/Loose_Comparison_True2", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE(Math::Similar(100, 99.999, 0.01));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that the similar function works with a loose comparison -> false
|
||||||
|
TEST_CASE(__FILE__"/Loose_Comparison_False", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE_FALSE(Math::Similar(100, 100.1, 0.01));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that the similar function works with a loose comparison -> false
|
||||||
|
TEST_CASE(__FILE__"/Loose_Comparison_False2", "[Math][Similar]")
|
||||||
|
{
|
||||||
|
REQUIRE_FALSE(Math::Similar(100, 99.9, 0.01));
|
||||||
|
return;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user