back to catch

This commit is contained in:
BlackMATov
2021-01-26 20:57:19 +07:00
parent c440789bee
commit ecee465511
13 changed files with 17964 additions and 6354 deletions

2
untests/catch/catch.cpp Normal file
View File

@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "catch.hpp"

17881
untests/catch/catch.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +0,0 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
#pragma once
#include "doctest.h"
#define STATIC_REQUIRE(...)\
static_assert(__VA_ARGS__, #__VA_ARGS__);\
REQUIRE(__VA_ARGS__);
#define STATIC_REQUIRE_FALSE(...)\
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
REQUIRE(!(__VA_ARGS__));

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
#include <set>
#include <map>
@@ -19,7 +19,7 @@ namespace
}
TEST_CASE("vmath/ext") {
SUBCASE("units") {
SECTION("units") {
STATIC_REQUIRE(zero2<int> == int2(0,0));
STATIC_REQUIRE(zero3<int> == int3(0,0,0));
STATIC_REQUIRE(zero4<int> == int4(0,0,0,0));
@@ -52,7 +52,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(identity4x4<int> == int4x4());
}
SUBCASE("vector hash") {
SECTION("vector hash") {
REQUIRE(std::hash<int2>{}({1,2}) == std::hash<int2>{}({1,2}));
REQUIRE_FALSE(std::hash<int2>{}({1,2}) == std::hash<int2>{}({2,1}));
@@ -90,7 +90,7 @@ TEST_CASE("vmath/ext") {
}
}
SUBCASE("matrix hash") {
SECTION("matrix hash") {
REQUIRE(std::hash<int2x2>{}({1,2,3,4}) == std::hash<int2x2>{}({1,2,3,4}));
REQUIRE_FALSE(std::hash<int2x2>{}({1,2,3,4}) == std::hash<int2x2>{}({1,2,4,3}));
@@ -122,7 +122,7 @@ TEST_CASE("vmath/ext") {
}
}
SUBCASE("quaternion hash") {
SECTION("quaternion hash") {
REQUIRE(std::hash<fqua>{}({1,2,3,4}) == std::hash<fqua>{}({1,2,3,4}));
REQUIRE_FALSE(std::hash<fqua>{}({1,2,3,4}) == std::hash<fqua>{}({3,2,1,4}));
@@ -154,7 +154,7 @@ TEST_CASE("vmath/ext") {
}
}
SUBCASE("cast_to") {
SECTION("cast_to") {
{
constexpr auto i = cast_to<int>(1.5f);
STATIC_REQUIRE(i == 1);
@@ -177,7 +177,7 @@ TEST_CASE("vmath/ext") {
}
}
SUBCASE("component") {
SECTION("component") {
STATIC_REQUIRE(component(int2{1,2}, 0) == 1);
STATIC_REQUIRE(component(int2{1,2}, 1) == 2);
@@ -185,7 +185,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(component(int2{0,0}, 1, 2) == int2{0,2});
}
SUBCASE("row") {
SECTION("row") {
STATIC_REQUIRE(row(int2x2(1,2,3,4), 0) == int2(1,2));
STATIC_REQUIRE(row(int2x2(1,2,3,4), 1) == int2(3,4));
@@ -193,7 +193,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(row(int2x2(), 1, {3,4}) == int2x2(1,0,3,4));
}
SUBCASE("column") {
SECTION("column") {
STATIC_REQUIRE(column(int2x2(1,2,3,4), 0) == int2(1,3));
STATIC_REQUIRE(column(int2x2(1,2,3,4), 1) == int2(2,4));
@@ -201,7 +201,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(column(int2x2(), 1, {3,4}) == int2x2(1,3,0,4));
}
SUBCASE("matrix translate") {
SECTION("matrix translate") {
STATIC_REQUIRE(float3(2.f,3.f,1.f) * translate(float2{1.f,2.f}) == uapprox3(3.f,5.f,1.f));
STATIC_REQUIRE(float3(2.f,3.f,1.f) * translate(translate(float2{1.f,2.f}), float2{1.f,2.f}) == uapprox3(4.f,7.f,1.f));
@@ -209,7 +209,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(float4(2.f,3.f,4.f,1.f) * translate(translate(float3{1.f,2.f,3.f}), float3{1.f,2.f,3.f}) == uapprox4(4.f,7.f,10.f,1.f));
}
SUBCASE("matrix rotate") {
SECTION("matrix rotate") {
constexpr float pi = radians(180.f);
constexpr float pi_2 = radians(90.f);
constexpr float pi_4 = radians(45.f);
@@ -231,7 +231,7 @@ TEST_CASE("vmath/ext") {
REQUIRE(float4(2.f,3.f,4.f,1.f) * rotate(rotate(pi_2,float3{0.f,0.f,1.f}),pi_2,float3{0.f,0.f,1.f}) == uapprox4(-2.f,-3.f,4.f,1.f));
}
SUBCASE("matrix scale") {
SECTION("matrix scale") {
STATIC_REQUIRE(float3(2.f,3.f,1.f) * scale(float2{2.f,3.f}) == uapprox3(4.f,9.f,1.f));
STATIC_REQUIRE(float4(2.f,3.f,4.f,1.f) * scale(float3{2.f,3.f,4.f}) == uapprox4(4.f,9.f,16.f,1.f));
STATIC_REQUIRE(float4(2.f,3.f,4.f,1.f) * scale(float3{2.f,3.f,4.f}) == uapprox4(4.f,9.f,16.f,1.f));
@@ -241,7 +241,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(float4(2.f,3.f,4.f,1.f) * scale(scale(float3{2.f,2.f,2.f}), float3{2.f,3.f,4.f}) == uapprox4(8.f,18.f,32.f,1.f));
}
SUBCASE("matrix shear") {
SECTION("matrix shear") {
STATIC_REQUIRE(float3(2.f,3.f,1.f) * shear_x(0.f) == uapprox3(2.f,3.f,1.f));
STATIC_REQUIRE(float3(2.f,3.f,1.f) * shear_x(1.f) == uapprox3(5.f,3.f,1.f));
STATIC_REQUIRE(float3(2.f,3.f,1.f) * shear_x(shear_x(1.f),1.f) == uapprox3(8.f,3.f,1.f));
@@ -257,7 +257,7 @@ TEST_CASE("vmath/ext") {
STATIC_REQUIRE(float3(2.f,3.f,1.f) * shear(shear(float2(0.f,1.f)),float2(0.f,1.f)) == uapprox3(2.f,7.f,1.f));
}
SUBCASE("matrix look_at") {
SECTION("matrix look_at") {
(void)look_at_lh(float3(-10.f), float3(0.f), float3(0,-1,0));
(void)look_at_rh(float3(-10.f), float3(0.f), float3(0,-1,0));
@@ -272,7 +272,7 @@ TEST_CASE("vmath/ext") {
(void)perspective_rh_no(1.f, 1.3f, 0.f, 10.f);
}
SUBCASE("vector angle") {
SECTION("vector angle") {
REQUIRE(angle(float2(2.f,0.f), float2(0.f,1.f)) == uapprox(radians(90.f)));
REQUIRE(angle(float2(0.f,3.f), float2(1.f,0.f)) == uapprox(radians(90.f)));
REQUIRE(angle(float2(0.5f,0.f), float2(-1.f,0.f)) == uapprox(radians(180.f)));
@@ -281,7 +281,7 @@ TEST_CASE("vmath/ext") {
REQUIRE(angle(float3(0.f,0.f,3.f), float3(0.f,1.f,0.f)) == uapprox(radians(90.f)));
}
SUBCASE("vector rotate") {
SECTION("vector rotate") {
REQUIRE(rotate(float2(2.f,0.f), radians(90.f)) == uapprox2(0.f,2.f));
REQUIRE(rotate(float2(1.5f,0.f), radians(-90.f)) == uapprox2(0.f,-1.5f));
@@ -292,12 +292,12 @@ TEST_CASE("vmath/ext") {
REQUIRE(rotate(float4(1.5f,0.f,0.f,1.f), radians(90.f), float3(0,0,1)) == uapprox4(0.f,1.5f,0.f,1.f));
}
SUBCASE("vector project") {
SECTION("vector project") {
REQUIRE(project(float2(2.f, 2.f), float2(0.f, 1.f)) == uapprox2(0.f, 2.f));
REQUIRE(project(float3(2.f, 2.f, 2.f), float3(0.f, 0.f, 1.f)) == uapprox3(0.f, 0.f, 2.f));
}
SUBCASE("quaternion qrotate") {
SECTION("quaternion qrotate") {
constexpr float pi = radians(180.f);
constexpr float pi_2 = radians(90.f);
constexpr float pi_4 = radians(45.f);

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -14,7 +14,7 @@ namespace
}
TEST_CASE("vmath/fun") {
SUBCASE("Angle and Trigonometry Functions") {
SECTION("Angle and Trigonometry Functions") {
STATIC_REQUIRE(radians(degrees(12.13f)) == uapprox(12.13f));
STATIC_REQUIRE(degrees(radians(12.13f)) == uapprox(12.13f));
@@ -43,7 +43,7 @@ TEST_CASE("vmath/fun") {
}
}
SUBCASE("Exponential Functions") {
SECTION("Exponential Functions") {
(void)pow(2.f, 3.f);
(void)exp(2.f);
(void)log(2.f);
@@ -53,7 +53,7 @@ TEST_CASE("vmath/fun") {
(void)rsqrt(2.f);
}
SUBCASE("Common Functions") {
SECTION("Common Functions") {
STATIC_REQUIRE(vmath_hpp::abs(1) == 1);
STATIC_REQUIRE(vmath_hpp::abs(-1) == 1);
STATIC_REQUIRE(vmath_hpp::abs(1.f) == uapprox(1.f));
@@ -121,7 +121,7 @@ TEST_CASE("vmath/fun") {
REQUIRE(ldexp(0.85f, 1) == uapprox(1.7f));
}
SUBCASE("Geometric Functions") {
SECTION("Geometric Functions") {
STATIC_REQUIRE(length(10.f) == uapprox(10.f));
STATIC_REQUIRE(length(-10.f) == uapprox(10.f));
@@ -142,7 +142,7 @@ TEST_CASE("vmath/fun") {
REQUIRE(refract(1.f, 2.f, 1.f) == uapprox(-7.f));
}
SUBCASE("Relational Functions") {
SECTION("Relational Functions") {
STATIC_REQUIRE_FALSE(any(false));
STATIC_REQUIRE_FALSE(any(0));
STATIC_REQUIRE(any(true));

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -31,7 +31,7 @@ namespace
}
TEST_CASE("vmath/mat_fun") {
SUBCASE("detail") {
SECTION("detail") {
STATIC_REQUIRE(map_join([](const int2& x){
return x * 2;
}, int2x2{}) == int2x2(2,0,0,2));
@@ -57,7 +57,7 @@ TEST_CASE("vmath/mat_fun") {
}, int2x2{}) == int2(1,1));
}
SUBCASE("operators") {
SECTION("operators") {
STATIC_REQUIRE(-int2x2(1,2,3,4) == int2x2(-1,-2,-3,-4));
STATIC_REQUIRE(~uint2x2(0xF0F0F0F0,0x0F0F0F0F,0xF0F0F0F0,0x0F0F0F0F) == uint2x2(0x0F0F0F0F,0xF0F0F0F0,0x0F0F0F0F,0xF0F0F0F0));
STATIC_REQUIRE(!int2x2(-1,0,1,2) == bool2x2(false,true,false,false));
@@ -163,7 +163,7 @@ TEST_CASE("vmath/mat_fun") {
}
}
SUBCASE("relational functions") {
SECTION("relational functions") {
STATIC_REQUIRE_FALSE(any(bool2x2(false, false, false, false)));
STATIC_REQUIRE(any(bool2x2(true, false, true, false)));
STATIC_REQUIRE(any(bool2x2(false, true, false, true)));
@@ -225,7 +225,7 @@ TEST_CASE("vmath/mat_fun") {
STATIC_REQUIRE(not_equal_to(1,int2x2(0,1,2,3)) == bool2x2(true, false, true, true));
}
SUBCASE("transpose") {
SECTION("transpose") {
STATIC_REQUIRE(transpose(int2x2(
1, 2,
3, 4
@@ -257,7 +257,7 @@ TEST_CASE("vmath/mat_fun") {
));
}
SUBCASE("determinant") {
SECTION("determinant") {
constexpr int2x2 m2{1,2,3,4};
constexpr int3x3 m3{1,2,3,4,5,6,7,8,9};
constexpr int4x4 m4{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
@@ -274,7 +274,7 @@ TEST_CASE("vmath/mat_fun") {
STATIC_REQUIRE(determinant(transpose(generate_frank_matrix<int, 4>())) == 1);
}
SUBCASE("inverse") {
SECTION("inverse") {
STATIC_REQUIRE(inverse(float2x2()) == float2x2());
STATIC_REQUIRE(inverse(float3x3()) == float3x3());
STATIC_REQUIRE(inverse(float4x4()) == float4x4());

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -14,7 +14,7 @@ namespace
}
TEST_CASE("vmath/mat") {
SUBCASE("size/sizeof") {
SECTION("size/sizeof") {
STATIC_REQUIRE(int2x2{}.size == 2);
STATIC_REQUIRE(int3x3{}.size == 3);
STATIC_REQUIRE(int4x4{}.size == 4);
@@ -24,7 +24,7 @@ TEST_CASE("vmath/mat") {
STATIC_REQUIRE(sizeof(int4x4{}) == sizeof(int) * 4 * 4);
}
SUBCASE("guides") {
SECTION("guides") {
STATIC_REQUIRE(mat{1,2,3,4}.size == 2);
STATIC_REQUIRE(mat{{1,2},{3,4}}.size == 2);
STATIC_REQUIRE(mat{vec{1,2},vec{3,4}}.size == 2);
@@ -40,7 +40,7 @@ TEST_CASE("vmath/mat") {
STATIC_REQUIRE(mat{mat{1,2,3,4,5,6,7,8,9},vec{5,6,7}}.size == 4);
}
SUBCASE("ctors") {
SECTION("ctors") {
{
STATIC_REQUIRE(int2x2()[0] == int2(1,0));
STATIC_REQUIRE(int2x2()[1] == int2(0,1));
@@ -93,7 +93,7 @@ TEST_CASE("vmath/mat") {
}
}
SUBCASE("operator=") {
SECTION("operator=") {
{
int2x2 v(1,2,3,4);
int2x2 v2;
@@ -108,7 +108,7 @@ TEST_CASE("vmath/mat") {
}
}
SUBCASE("swap") {
SECTION("swap") {
{
int2x2 v1(1,2,3,4);
int2x2 v2(4,5,6,7);
@@ -125,7 +125,7 @@ TEST_CASE("vmath/mat") {
}
}
SUBCASE("iter") {
SECTION("iter") {
{
int2x2 m{1,2,3,4};
@@ -195,7 +195,7 @@ TEST_CASE("vmath/mat") {
}
}
SUBCASE("data") {
SECTION("data") {
{
int2x2 m2;
REQUIRE(m2.data() == &m2[0]);
@@ -218,7 +218,7 @@ TEST_CASE("vmath/mat") {
}
}
SUBCASE("operator[]") {
SECTION("operator[]") {
{
STATIC_REQUIRE(int2x2()[0] == int2(1,0));
STATIC_REQUIRE(int2x2()[1] == int2(0,1));
@@ -255,13 +255,13 @@ TEST_CASE("vmath/mat") {
}
}
SUBCASE("at") {
SECTION("at") {
STATIC_REQUIRE(int2x2(1,2,3,4).at(0) == int2(1,2));
STATIC_REQUIRE(int2x2(1,2,3,4).at(1) == int2(3,4));
REQUIRE_THROWS_AS((void)int2x2(1,2,3,4).at(2), std::out_of_range);
}
SUBCASE("operator==/operator!=") {
SECTION("operator==/operator!=") {
STATIC_REQUIRE(int2x2(1,2,3,4) == int2x2(1,2,3,4));
STATIC_REQUIRE_FALSE(int2x2(1,2,3,4) == int2x2(2,2,3,4));
STATIC_REQUIRE_FALSE(int2x2(1,2,3,4) == int2x2(1,3,3,4));
@@ -271,7 +271,7 @@ TEST_CASE("vmath/mat") {
STATIC_REQUIRE(int2x2(1,2,3,4) != int2x2(1,3,3,4));
}
SUBCASE("operator<") {
SECTION("operator<") {
STATIC_REQUIRE_FALSE(int2x2(1,2,3,4) < int2x2(1,2,3,4));
STATIC_REQUIRE(int2x2(1,1,3,4) < int2x2(1,2,3,4));

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -14,7 +14,7 @@ namespace
}
TEST_CASE("vmath/qua_fun") {
SUBCASE("Operators") {
SECTION("Operators") {
STATIC_REQUIRE(+qua(1,-2,3,-4) == qua(1,-2,3,-4));
STATIC_REQUIRE(-qua(1,-2,3,-4) == qua(-1,2,-3,4));
@@ -72,13 +72,13 @@ TEST_CASE("vmath/qua_fun") {
STATIC_REQUIRE(float4{1,0,0,2} * fqua{0,0,0.7071067812f,0.7071067812f} == uapprox4(0.f,1.f,0.f,2.f));
}
SUBCASE("Common Functions") {
SECTION("Common Functions") {
REQUIRE_FALSE(any(isnan(fqua(1,1,1,1))));
REQUIRE_FALSE(any(isinf(fqua(1,1,1,1))));
REQUIRE(all(isfinite(fqua(1,1,1,1))));
}
SUBCASE("Geometric Functions") {
SECTION("Geometric Functions") {
STATIC_REQUIRE(dot(qua(1,2,3,4),qua(3,4,5,6)) == 50);
REQUIRE(length(fqua(10.f,0.f,0.f,0.f)) == uapprox(10.f));
@@ -90,7 +90,7 @@ TEST_CASE("vmath/qua_fun") {
REQUIRE(normalize(fqua(0.5f,0.f,0.f,0.f)).v == uapprox3(1.f,0.f,0.f));
}
SUBCASE("Relational Functions") {
SECTION("Relational Functions") {
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3)) == bool4(false, true, false, false));
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3), 0) == bool4(false, true, false, false));
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3), 1) == bool4(true, true, true, false));
@@ -100,7 +100,7 @@ TEST_CASE("vmath/qua_fun") {
STATIC_REQUIRE(not_equal_to(qua(1,1,1,1), qua(0,1,2,3)) == bool4(true, false, true, true));
}
SUBCASE("Quaternion Functions") {
SECTION("Quaternion Functions") {
STATIC_REQUIRE(conjugate(qua(1,2,3,4)) == qua(-1,-2,-3,4));
STATIC_REQUIRE(inverse(qua(0.f,0.f,0.7071067812f,0.7071067812f)).v == uapprox3(0.f,0.f,-0.7071067812f));
STATIC_REQUIRE(inverse(qua(0.f,0.f,0.7071067812f,0.7071067812f)).s == uapprox(0.7071067812f));

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -14,7 +14,7 @@ namespace
}
TEST_CASE("vmath/qua") {
SUBCASE("size/sizeof") {
SECTION("size/sizeof") {
STATIC_REQUIRE(fqua{}.size == 4);
STATIC_REQUIRE(dqua{}.size == 4);
@@ -22,7 +22,7 @@ TEST_CASE("vmath/qua") {
STATIC_REQUIRE(sizeof(dqua{}) == sizeof(double) * 4);
}
SUBCASE("guides") {
SECTION("guides") {
STATIC_REQUIRE(qua{1,2,3,4}.size == 4);
STATIC_REQUIRE(qua{{1,2,3},4}.size == 4);
STATIC_REQUIRE(qua{vec{1,2,3},4}.size == 4);
@@ -30,7 +30,7 @@ TEST_CASE("vmath/qua") {
STATIC_REQUIRE(qua(vec{1,2,3,4}).size == 4);
}
SUBCASE("ctors") {
SECTION("ctors") {
{
STATIC_REQUIRE(fqua{}.v == uapprox3(0.f));
STATIC_REQUIRE(fqua{}.s == uapprox(1.f));
@@ -61,7 +61,7 @@ TEST_CASE("vmath/qua") {
}
}
SUBCASE("operator=") {
SECTION("operator=") {
{
fqua v(1,2,3,4);
fqua v2;
@@ -76,7 +76,7 @@ TEST_CASE("vmath/qua") {
}
}
SUBCASE("swap") {
SECTION("swap") {
{
fqua v1(1,2,3,4);
fqua v2(4,5,6,7);
@@ -93,7 +93,7 @@ TEST_CASE("vmath/qua") {
}
}
SUBCASE("iter") {
SECTION("iter") {
{
fqua v{1,2,3,4};
@@ -163,7 +163,7 @@ TEST_CASE("vmath/qua") {
}
}
SUBCASE("data") {
SECTION("data") {
{
fqua i2;
REQUIRE(i2.data() == &i2[0]);
@@ -174,7 +174,7 @@ TEST_CASE("vmath/qua") {
}
}
SUBCASE("operator[]") {
SECTION("operator[]") {
{
STATIC_REQUIRE(qua(1,2,3,4).v == vec(1,2,3));
STATIC_REQUIRE(qua(1,2,3,4).s == 4);
@@ -193,7 +193,7 @@ TEST_CASE("vmath/qua") {
}
}
SUBCASE("at") {
SECTION("at") {
STATIC_REQUIRE(fqua(1,2,3,4).at(0) == 1);
STATIC_REQUIRE(fqua(1,2,3,4).at(1) == 2);
STATIC_REQUIRE(fqua(1,2,3,4).at(2) == 3);
@@ -201,7 +201,7 @@ TEST_CASE("vmath/qua") {
REQUIRE_THROWS_AS((void)fqua(1,2,3,4).at(4), std::out_of_range);
}
SUBCASE("operator==/operator!=") {
SECTION("operator==/operator!=") {
STATIC_REQUIRE(fqua(1,2,3,4) == fqua(1,2,3,4));
STATIC_REQUIRE_FALSE(fqua(1,2,3,4) == fqua(2,2,3,4));
STATIC_REQUIRE_FALSE(fqua(1,2,3,4) == fqua(1,3,3,4));
@@ -211,7 +211,7 @@ TEST_CASE("vmath/qua") {
STATIC_REQUIRE(fqua(1,2,3,4) != fqua(1,3,3,4));
}
SUBCASE("operator<") {
SECTION("operator<") {
STATIC_REQUIRE_FALSE(fqua(1,2,3,4) < fqua(1,2,3,4));
STATIC_REQUIRE(fqua(0,2,3,4) < fqua(1,2,3,4));

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -14,7 +14,7 @@ namespace
}
TEST_CASE("vmath/vec_fun") {
SUBCASE("Detail") {
SECTION("Detail") {
STATIC_REQUIRE(map_join([](const int& x){
return x * 2;
}, int2{1}) == int2{2});
@@ -40,7 +40,7 @@ TEST_CASE("vmath/vec_fun") {
}, int2{1}) == 2);
}
SUBCASE("Operators") {
SECTION("Operators") {
STATIC_REQUIRE(-int2(1,-2) == int2(-1,2));
STATIC_REQUIRE(~uint2(0xF0F0F0F0,0x0F0F0F0F) == uint2(0x0F0F0F0F,0xF0F0F0F0));
STATIC_REQUIRE(!int3(-1,0,1) == bool3(false, true, false));
@@ -129,7 +129,7 @@ TEST_CASE("vmath/vec_fun") {
}
}
SUBCASE("Angle and Trigonometry Functions") {
SECTION("Angle and Trigonometry Functions") {
STATIC_REQUIRE(radians(degrees(float2(12.13f))) == uapprox2(12.13f));
STATIC_REQUIRE(degrees(radians(float2(12.13f))) == uapprox2(12.13f));
@@ -158,7 +158,7 @@ TEST_CASE("vmath/vec_fun") {
}
}
SUBCASE("Exponential Functions") {
SECTION("Exponential Functions") {
(void)pow(float2(1.f), float2(2.f));
(void)exp(float2(1.f));
(void)log(float2(1.f));
@@ -168,7 +168,7 @@ TEST_CASE("vmath/vec_fun") {
(void)rsqrt(float2(1.f));
}
SUBCASE("Common Functions") {
SECTION("Common Functions") {
STATIC_REQUIRE(abs(float2(1.f, -1.f)) == uapprox2(1.f,1.f));
STATIC_REQUIRE(sign(float3(1.f, -1.f, 0.f)) == uapprox3(1.f,-1.f,0.f));
STATIC_REQUIRE(rcp(float2(2.f, 4.f)) == uapprox2(0.5f,0.25f));
@@ -227,7 +227,7 @@ TEST_CASE("vmath/vec_fun") {
REQUIRE(ldexp(float2(0.85f), int2(1)).x == uapprox(1.7f));
}
SUBCASE("Geometric Functions") {
SECTION("Geometric Functions") {
REQUIRE(length(float2(10.f,0.f)) == uapprox(10.f));
REQUIRE(length(float2(-10.f,0.f)) == uapprox(10.f));
@@ -250,7 +250,7 @@ TEST_CASE("vmath/vec_fun") {
REQUIRE(refract(float2(1.f), float2(2.f), 1.f).x == uapprox(-15.f));
}
SUBCASE("Relational Functions") {
SECTION("Relational Functions") {
STATIC_REQUIRE_FALSE(any(bool2(false, false)));
STATIC_REQUIRE(any(bool2(true, false)));
STATIC_REQUIRE(any(bool2(false, true)));

View File

@@ -5,7 +5,7 @@
******************************************************************************/
#include "vmath_tests.hpp"
#include "doctest/doctest.hpp"
#include "catch/catch.hpp"
namespace
{
@@ -14,7 +14,7 @@ namespace
}
TEST_CASE("vmath/vec") {
SUBCASE("size/sizeof") {
SECTION("size/sizeof") {
STATIC_REQUIRE(int2{}.size == 2);
STATIC_REQUIRE(int3{}.size == 3);
STATIC_REQUIRE(int4{}.size == 4);
@@ -24,7 +24,7 @@ TEST_CASE("vmath/vec") {
STATIC_REQUIRE(sizeof(int4{}) == sizeof(int) * 4);
}
SUBCASE("guides") {
SECTION("guides") {
STATIC_REQUIRE(vec{1,2}.size == 2);
STATIC_REQUIRE(vec{1,2,3}.size == 3);
@@ -40,7 +40,7 @@ TEST_CASE("vmath/vec") {
STATIC_REQUIRE(vec{1,vec{2,3,4}}.size == 4);
}
SUBCASE("ctors") {
SECTION("ctors") {
{
STATIC_REQUIRE(int2().x == 0);
STATIC_REQUIRE(int2().y == 0);
@@ -86,7 +86,7 @@ TEST_CASE("vmath/vec") {
}
}
SUBCASE("operator=") {
SECTION("operator=") {
{
int2 v(1,2);
int2 v2;
@@ -101,7 +101,7 @@ TEST_CASE("vmath/vec") {
}
}
SUBCASE("swap") {
SECTION("swap") {
{
int2 v1(1,2);
int2 v2(4,5);
@@ -118,7 +118,7 @@ TEST_CASE("vmath/vec") {
}
}
SUBCASE("iter") {
SECTION("iter") {
{
int2 v{1,2};
@@ -188,7 +188,7 @@ TEST_CASE("vmath/vec") {
}
}
SUBCASE("data") {
SECTION("data") {
{
int2 i2;
REQUIRE(i2.data() == &i2[0]);
@@ -211,7 +211,7 @@ TEST_CASE("vmath/vec") {
}
}
SUBCASE("operator[]") {
SECTION("operator[]") {
{
STATIC_REQUIRE(int2(1,2).x == 1);
STATIC_REQUIRE(int2(1,2).y == 2);
@@ -252,13 +252,13 @@ TEST_CASE("vmath/vec") {
}
}
SUBCASE("at") {
SECTION("at") {
STATIC_REQUIRE(int2(1,2).at(0) == 1);
STATIC_REQUIRE(int2(1,2).at(1) == 2);
REQUIRE_THROWS_AS((void)int2(1,2).at(2), std::out_of_range);
}
SUBCASE("operator==/operator!=") {
SECTION("operator==/operator!=") {
STATIC_REQUIRE(int2(1,2) == int2(1,2));
STATIC_REQUIRE_FALSE(int2(1,2) == int2(2,2));
STATIC_REQUIRE_FALSE(int2(1,2) == int2(1,3));
@@ -268,7 +268,7 @@ TEST_CASE("vmath/vec") {
STATIC_REQUIRE(int2(1,2) != int2(1,3));
}
SUBCASE("operator<") {
SECTION("operator<") {
STATIC_REQUIRE_FALSE(int2(1,2) < int2(1,2));
STATIC_REQUIRE(int2(1,1) < int2(1,2));