Translated tests for Random/RandomFloat
This commit is contained in:
parent
c5b12c0c20
commit
fe212cd039
@ -24,6 +24,7 @@ add_executable(Tests
|
|||||||
Vector3.cpp
|
Vector3.cpp
|
||||||
Vector4.cpp
|
Vector4.cpp
|
||||||
Quaternion.cpp
|
Quaternion.cpp
|
||||||
|
Random__RandomFloat.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(Tests Eule)
|
target_link_libraries(Tests Eule)
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
#include "CppUnitTest.h"
|
#include "Catch2.h"
|
||||||
#include "../Eule/Random.h"
|
#include <Eule/Random.h>
|
||||||
|
|
||||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
||||||
using namespace Eule;
|
using namespace Eule;
|
||||||
|
|
||||||
namespace _Random
|
// Checks that all values are always 0 <= v <= 1
|
||||||
|
TEST_CASE(__FILE__"/Always_Satisfies_0_lt_v_lt_1", "[Random][RandomFloat]")
|
||||||
{
|
{
|
||||||
TEST_CLASS(_RandomFloat)
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Checks that all values are always 0 <= v <= 1
|
|
||||||
TEST_METHOD(Always_Satisfies_0_lt_v_lt_1)
|
|
||||||
{
|
|
||||||
// Test 1000 random values
|
// Test 1000 random values
|
||||||
for (std::size_t i = 0; i < 1e3; i++)
|
for (std::size_t i = 0; i < 1e3; i++)
|
||||||
{
|
{
|
||||||
const double rnd = Random::RandomFloat();
|
const double rnd = Random::RandomFloat();
|
||||||
Assert::IsTrue(rnd >= 0.0, L"rnd < 0");
|
INFO("rnd < 0");
|
||||||
Assert::IsTrue(rnd <= 1.0, L"rnd > 1");
|
REQUIRE(rnd >= 0.0);
|
||||||
|
|
||||||
|
INFO("rnd > 1");
|
||||||
|
REQUIRE(rnd <= 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user