Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(tests): tidying up unittests for vec2_t
- Loading branch information
Showing
2 changed files
with
62 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <catch2/catch.hpp> | ||
#include <math/vec2_t.hpp> | ||
#include <math/vec3_t.hpp> | ||
#include <math/vec4_t.hpp> | ||
#include <math/mat3_t.hpp> | ||
#include <math/quat_t.hpp> | ||
#include <math/mat4_t.hpp> | ||
|
||
// NOLINTNEXTLINE | ||
#define gen_random_value(T, range_min, range_max, Nsamples) \ | ||
GENERATE(take(Nsamples, random(static_cast<T>(range_min), \ | ||
static_cast<T>(range_max)))) | ||
|
||
namespace math { | ||
|
||
template <typename T> | ||
constexpr auto func_value_close(T a, T b, T eps) -> bool { | ||
return ((a - b) < eps) && ((a - b) > -eps); | ||
} | ||
|
||
template <typename T> | ||
constexpr auto func_all_close(const ::math::Vector2<T>& vec, T x, T y, T eps) | ||
-> bool { | ||
return func_value_close(vec.x(), x, eps) && | ||
func_value_close(vec.y(), y, eps); | ||
} | ||
|
||
} // namespace math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters