From fe212cd03984d44cc9078cf1cd27a73034cda505 Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Fri, 11 Feb 2022 14:55:26 +0100 Subject: [PATCH] Translated tests for Random/RandomFloat --- Test/CMakeLists.txt | 1 + Test/Random__RandomFloat.cpp | 35 +++++++++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt index d902ce0..fb224ea 100644 --- a/Test/CMakeLists.txt +++ b/Test/CMakeLists.txt @@ -24,6 +24,7 @@ add_executable(Tests Vector3.cpp Vector4.cpp Quaternion.cpp + Random__RandomFloat.cpp ) target_link_libraries(Tests Eule) diff --git a/Test/Random__RandomFloat.cpp b/Test/Random__RandomFloat.cpp index 40c128a..a1ad36d 100644 --- a/Test/Random__RandomFloat.cpp +++ b/Test/Random__RandomFloat.cpp @@ -1,26 +1,21 @@ -#include "CppUnitTest.h" -#include "../Eule/Random.h" +#include "Catch2.h" +#include -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; }