mirror of
https://github.com/thunderbrewhq/typhoon.git
synced 2026-05-04 22:33:51 +00:00
feat: sync with Whoa implementation
This commit is contained in:
parent
254ba545f5
commit
6a31dc3ea4
19 changed files with 988 additions and 774 deletions
37
test/Random.cpp
Normal file
37
test/Random.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "tempest/Random.hpp"
|
||||
#include "test/Test.hpp"
|
||||
|
||||
TEST_CASE("CRandom::dice", "[random]") {
|
||||
SECTION("generates numbers within range") {
|
||||
auto seed = CRndSeed(0xC0D1E2F3);
|
||||
|
||||
for (int32_t i = 0; i < 200; i++) {
|
||||
auto result1 = CRandom::dice(0, seed);
|
||||
REQUIRE(result1 == 0);
|
||||
|
||||
auto result2 = CRandom::dice(1, seed);
|
||||
REQUIRE(result2 == 0);
|
||||
|
||||
auto result3 = CRandom::dice(2, seed);
|
||||
REQUIRE(result3 < 2);
|
||||
|
||||
auto result4 = CRandom::dice(10, seed);
|
||||
REQUIRE(result4 < 10);
|
||||
|
||||
auto result5 = CRandom::dice(100, seed);
|
||||
REQUIRE(result5 < 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("CRandom::uint32", "[random]") {
|
||||
SECTION("generates expected numbers for given seed") {
|
||||
auto seed = CRndSeed(0x294823);
|
||||
|
||||
auto result1 = CRandom::uint32(seed);
|
||||
REQUIRE(result1 == 0xC0D0F1AE);
|
||||
|
||||
auto result2 = CRandom::uint32(seed);
|
||||
REQUIRE(result2 == 0x5CA56410);
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,16 @@ TEST_CASE("C3Vector", "[vector]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("C3Vector::operator-", "[vector]") {
|
||||
SECTION("returns vector with negated values") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
auto negated = -vector;
|
||||
CHECK(negated.x == -1.0f);
|
||||
CHECK(negated.y == -2.0f);
|
||||
CHECK(negated.z == -3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("C3Vector::operator*=", "[vector]") {
|
||||
SECTION("multiplies by 2.0f") {
|
||||
auto vector = C3Vector(1.0f, 2.0f, 3.0f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue