Files
j3ml/tests/MathFuncTests.hpp

83 lines
2.2 KiB
C++

/// Josh's 3D Math Library
/// A C++20 Library for 3D Math, Computer Graphics, and Scientific Computing.
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
/// Special Thanks to William Tomasine II and Maxine Hayes.
/// (c) 2024 Redacted Software
/// This work is dedicated to the public domain.
/// @file MathFuncTests.hpp
/// @desc Unit tests for core math functions
/// @edit 2024-07-06
#pragma once
#include <jtest/jtest.hpp>
#include "J3ML/J3ML.hpp"
inline void MathFuncTests()
{
using namespace jtest;
using namespace J3ML::Math;
TEST("Math::IsFinite", [] {
check(IsFinite<u32>(420));
check(IsFinite<u64>(25));
check(IsFinite(5.f));
check(IsFinite(5.0));
check(!IsFinite(Infinity));
check(!IsFinite(NotANumber));
});
TEST("Math::IsNotANumber", [] {
check(!IsNotANumber(5.f));
check(!IsNotANumber(5.0));
check(IsNotANumber(NotANumber));
check(!IsNotANumber(Infinity));
});
TEST("Math::IsInfinite", [] {
check(!IsInfinite(5.f));
check(!IsInfinite(5.0));
check(IsInfinite(Infinity));
});
TEST("Math::ReinterpretAsU32", [] {
check(ReinterpretAs<u32>(0.f) == 0x00000000);
check(ReinterpretAs<u32>(1.f) == 0x3F800000);
check(ReinterpretAs<u32>(2.f) == 0x40000000);
check(ReinterpretAs<u32>(-1.f) == 0xBF800000);
check(ReinterpretAs<u32>(Infinity) == 0x7F800000);
});
TEST("Math::ReinterpretAsFloat", [] {
check(ReinterpretAs<float, u32>(0x00000000) == 0.f);
check(ReinterpretAs<float, u32>(0x3F800000) == 1.f);
check(ReinterpretAs<float, u32>(0x40000000) == 2.f);
check(ReinterpretAs<float, u32>(0xBF800000) == -1.f);
check(ReinterpretAs<float>(0x7F800000) == Infinity);
check(IsNotANumber(ReinterpretAs<float>(0x7F800001)));
});
TEST("Math::SqrtVals", [] {
});
TEST("Math::SqrtPrecision", [] {
});
TEST("Math::SqrtRSqrtPrecision", [] {
});
TEST("Math::SqrtRecipPrecision", [] {
});
TEST("Math::Min", [] {});
TEST("Math::Max", [] {});
TEST("Math::IsPow2", [] {});
}