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