Translated tests for Random/RandomFloat

This commit is contained in:
Leonetienne 2022-02-11 14:55:26 +01:00
parent c5b12c0c20
commit fe212cd039
2 changed files with 16 additions and 20 deletions

View File

@ -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)

View File

@ -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) // Test 1000 random values
{ for (std::size_t i = 0; i < 1e3; i++)
public: {
// Checks that all values are always 0 <= v <= 1 const double rnd = Random::RandomFloat();
TEST_METHOD(Always_Satisfies_0_lt_v_lt_1) INFO("rnd < 0");
{ REQUIRE(rnd >= 0.0);
// 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");
}
return; INFO("rnd > 1");
} REQUIRE(rnd <= 1.0);
}; }
return;
} }