58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#ifdef TESTS_BUILD
|
|
#include "../extern/catch.hpp"
|
|
#include "../src/Core/Random.hpp"
|
|
|
|
TEST_CASE( "Random ints", "[Utilities]" ) {
|
|
auto rand = CreatureLib::Core::Random(10);
|
|
CHECK(rand.Get() == 1656398469);
|
|
CHECK(rand.Get() == 641584702);
|
|
CHECK(rand.Get() == 44564466);
|
|
CHECK(rand.Get() == 1062123783);
|
|
CHECK(rand.Get() == 1360749216);
|
|
CHECK(rand.Get() == 951367352);
|
|
CHECK(rand.Get() == 1608044094);
|
|
CHECK(rand.Get() == 1786516046);
|
|
CHECK(rand.Get() == 1070535660);
|
|
CHECK(rand.Get() == 1252673902);
|
|
}
|
|
|
|
TEST_CASE( "Random ints with limit", "[Utilities]" ) {
|
|
auto rand = CreatureLib::Core::Random(10);
|
|
CHECK(rand.Get(10) == 7);
|
|
CHECK(rand.Get(10) == 2);
|
|
CHECK(rand.Get(10) == 0);
|
|
CHECK(rand.Get(10) == 4);
|
|
CHECK(rand.Get(10) == 6);
|
|
CHECK(rand.Get(10) == 4);
|
|
CHECK(rand.Get(10) == 7);
|
|
CHECK(rand.Get(10) == 8);
|
|
CHECK(rand.Get(10) == 4);
|
|
CHECK(rand.Get(10) == 5);
|
|
|
|
CHECK(rand.Get(2) == 0);
|
|
CHECK(rand.Get(2) == 0);
|
|
CHECK(rand.Get(2) == 0);
|
|
CHECK(rand.Get(2) == 1);
|
|
CHECK(rand.Get(2) == 1);
|
|
CHECK(rand.Get(2) == 0);
|
|
CHECK(rand.Get(2) == 0);
|
|
CHECK(rand.Get(2) == 0);
|
|
CHECK(rand.Get(2) == 0);
|
|
|
|
}
|
|
|
|
TEST_CASE( "Random ints with upper and bottom", "[Utilities]" ) {
|
|
auto rand = CreatureLib::Core::Random(10);
|
|
CHECK(rand.Get(10, 30) == 25);
|
|
CHECK(rand.Get(10, 30) == 15);
|
|
CHECK(rand.Get(10, 30) == 10);
|
|
CHECK(rand.Get(10, 30) == 19);
|
|
CHECK(rand.Get(10, 30) == 22);
|
|
CHECK(rand.Get(10, 30) == 18);
|
|
CHECK(rand.Get(10, 30) == 24);
|
|
CHECK(rand.Get(10, 30) == 26);
|
|
CHECK(rand.Get(10, 30) == 19);
|
|
CHECK(rand.Get(10, 30) == 21);
|
|
}
|
|
|
|
#endif |