start to refactor for C++23
This commit is contained in:
parent
42c7221318
commit
cd19543627
19 changed files with 489 additions and 434 deletions
66
tests/pw_test_core.cpp
Normal file
66
tests/pw_test_core.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include <snitch/snitch.hpp>
|
||||
|
||||
#include <pw/core/matrix.hpp>
|
||||
#include <pw/core/vector.hpp>
|
||||
|
||||
|
||||
TEST_CASE("core", "[matrix]") {
|
||||
|
||||
auto m44 = pw::matrix_<2, 2, float>{};
|
||||
|
||||
REQUIRE(m44(0, 0) == 0);
|
||||
REQUIRE(m44(0, 1) == 0);
|
||||
REQUIRE(m44(1, 0) == 0);
|
||||
REQUIRE(m44(1, 1) == 0);
|
||||
|
||||
m44 = pw::matrix2x2_<float>::all(42.42f);
|
||||
|
||||
REQUIRE(m44(0, 0) == 42.42f);
|
||||
REQUIRE(m44(0, 1) == 42.42f);
|
||||
REQUIRE(m44(1, 0) == 42.42f);
|
||||
REQUIRE(m44(1, 1) == 42.42f);
|
||||
|
||||
m44 *= 2;
|
||||
REQUIRE(m44(0, 0) == 84.84f);
|
||||
REQUIRE(m44(0, 1) == 84.84f);
|
||||
REQUIRE(m44(1, 0) == 84.84f);
|
||||
REQUIRE(m44(1, 1) == 84.84f);
|
||||
|
||||
m44.set_identity();
|
||||
REQUIRE(m44(0, 0) == 1.0f);
|
||||
REQUIRE(m44(0, 1) == 0.0f);
|
||||
REQUIRE(m44(1, 0) == 0.0f);
|
||||
REQUIRE(m44(1, 1) == 1.0f);
|
||||
|
||||
auto m44_2 = pw::matrix2x2::make(0, 1, 2, 3);
|
||||
|
||||
REQUIRE(m44_2(0, 0) == 0.0f);
|
||||
REQUIRE(m44_2(1, 0) == 1.0f);
|
||||
REQUIRE(m44_2(0, 1) == 2.0f);
|
||||
REQUIRE(m44_2(1, 1) == 3.0f);
|
||||
|
||||
|
||||
pw::matrix2x2 m44_3 = {{},{1, 2, 3, 4}};
|
||||
|
||||
REQUIRE(m44_3(0, 0) == 1.0f);
|
||||
REQUIRE(m44_3(1, 0) == 2.0f);
|
||||
REQUIRE(m44_3(0, 1) == 3.0f);
|
||||
REQUIRE(m44_3(1, 1) == 4.0f);
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("core", "[vector]") {
|
||||
|
||||
auto vec4_1 = pw::vector4_<float>{};
|
||||
auto vec4_2 = pw::vector4::make(1, 2, 3, 4);
|
||||
|
||||
auto vec4_3 = vec4_1 + vec4_2;
|
||||
|
||||
REQUIRE(vec4_3[0] == 1.0f);
|
||||
REQUIRE(vec4_3[1] == 2.0f);
|
||||
REQUIRE(vec4_3[2] == 3.0f);
|
||||
REQUIRE(vec4_3[3] == 4.0f);
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue