mirror of
https://github.com/orange-cpp/omath.git
synced 2026-06-12 02:04:35 +00:00
now add constexpr gcem tests for triangle and mat classes
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
// Created by Orange on 11/30/2024.
|
||||
//
|
||||
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <cmath>
|
||||
#include <gtest/gtest.h>
|
||||
#include <numbers>
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
|
||||
using namespace omath;
|
||||
|
||||
@@ -19,6 +19,14 @@ namespace
|
||||
|
||||
constexpr float k_eps = 1e-5f;
|
||||
|
||||
#ifdef OMATH_USE_GCEM
|
||||
constexpr bool close_to(const float actual, const float expected, const float epsilon)
|
||||
{
|
||||
const float diff = actual - expected;
|
||||
return (diff < 0.0f ? -diff : diff) <= epsilon;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
// ---------- Construction / factories ----------
|
||||
@@ -190,3 +198,11 @@ TEST(UnitTestAngle, BinaryMinus_ReturnsWrappedDiff)
|
||||
const Deg c = a - b; // expect 340°
|
||||
EXPECT_FLOAT_EQ(c.as_degrees(), 340.0f);
|
||||
}
|
||||
|
||||
#ifdef OMATH_USE_GCEM
|
||||
static_assert(close_to(Pitch::from_degrees(0.0f).sin(), 0.0f, k_eps), "Sin should be constexpr with gcem");
|
||||
static_assert(close_to(Pitch::from_degrees(0.0f).cos(), 1.0f, k_eps), "Cos should be constexpr with gcem");
|
||||
static_assert(close_to(Pitch::from_degrees(45.0f).tan(), 1.0f, 1e-4f), "Tan should be constexpr with gcem");
|
||||
static_assert(close_to(Pitch::from_degrees(45.0f).cot(), 1.0f, 1e-4f), "Cot should be constexpr with gcem");
|
||||
static_assert(close_to(Pitch::from_degrees(45.0f).atan(), 0.66577375f, 1e-6f), "Atan should be constexpr with gcem");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user