Merge pull request #121 from luadebug/try

Run unit tests for WASM
This commit is contained in:
2025-12-22 00:34:28 +03:00
committed by GitHub
3 changed files with 14 additions and 4 deletions

View File

@@ -506,6 +506,14 @@ jobs:
cmake-build/build/${{ matrix.preset }}/**/*.log cmake-build/build/${{ matrix.preset }}/**/*.log
${{ env.VCPKG_ROOT }}/buildtrees/**/*.log ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run WASM Unit Tests
run: node out/Release/unit_tests.js
############################################################################## ##############################################################################
# 8) Windows MSYS2 MinGW GCC / Ninja # 8) Windows MSYS2 MinGW GCC / Ninja
############################################################################## ##############################################################################

View File

@@ -233,10 +233,10 @@ namespace omath
return Angle<float, 0.f, 180.f, AngleFlags::Clamped>::from_radians(std::acos(dot(other) / bottom)); return Angle<float, 0.f, 180.f, AngleFlags::Clamped>::from_radians(std::acos(dot(other) / bottom));
} }
[[nodiscard]] bool is_perpendicular(const Vector3& other) const noexcept [[nodiscard]] bool is_perpendicular(const Vector3& other, Type epsilon = static_cast<Type>(0.0001)) const noexcept
{ {
if (const auto angle = angle_between(other)) if (const auto angle = angle_between(other))
return angle->as_degrees() == static_cast<Type>(90); return std::abs(angle->as_degrees() - static_cast<Type>(90)) <= epsilon;
return false; return false;
} }

View File

@@ -390,8 +390,10 @@ TEST_F(UnitTestVector3, AsTuple)
// Test AsTuple method // Test AsTuple method
TEST_F(UnitTestVector3, AngleBeatween) TEST_F(UnitTestVector3, AngleBeatween)
{ {
EXPECT_EQ(Vector3(0.0f, 0.0f, 1.0f).angle_between({1, 0 ,0}).value().as_degrees(), 90.0f); EXPECT_NEAR(Vector3(0.0f, 0.0f, 1.0f).angle_between({1, 0, 0}).value().as_degrees(),
EXPECT_EQ(Vector3(0.0f, 0.0f, 1.0f).angle_between({0.0f, 0.0f, 1.0f}).value().as_degrees(), 0.0f); 90.0f, 0.001f);
EXPECT_NEAR(Vector3(0.0f, 0.0f, 1.0f).angle_between({0.0f, 0.0f, 1.0f}).value().as_degrees(),
0.0f, 0.001f);
EXPECT_FALSE(Vector3(0.0f, 0.0f, 0.0f).angle_between({0.0f, 0.0f, 1.0f}).has_value()); EXPECT_FALSE(Vector3(0.0f, 0.0f, 0.0f).angle_between({0.0f, 0.0f, 1.0f}).has_value());
} }