nodiscard for ext functions

This commit is contained in:
BlackMATov
2020-11-26 22:27:51 +07:00
parent 7861cc69cf
commit a8f242acd6
2 changed files with 87 additions and 56 deletions

View File

@@ -11,6 +11,11 @@
#include "vmath_tests.hpp"
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
namespace
{
using namespace vmath_hpp;
@@ -63,6 +68,32 @@ TEST_CASE("vmath/ext") {
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}));
{
std::set<int2> s;
s.insert(int2(1,2));
REQUIRE(s.count(int2(1,2)) > 0);
REQUIRE_FALSE(s.count(int2(1,1)) > 0);
}
{
std::map<int2, int> s;
s.emplace(int2(1,2),3);
s.emplace(int2(2,3),5);
REQUIRE(s[int2(1,2)] == 3);
REQUIRE(s[int2(2,3)] == 5);
}
{
std::unordered_set<int2> s;
s.insert(int2(1,2));
REQUIRE(s.count(int2(1,2)) > 0);
REQUIRE_FALSE(s.count(int2(1,1)) > 0);
}
{
std::unordered_map<int2, int> s;
s.emplace(int2(1,2),3);
s.emplace(int2(2,3),5);
REQUIRE(s[int2(1,2)] == 3);
REQUIRE(s[int2(2,3)] == 5);
}
}
SECTION("cast_to") {
@@ -155,18 +186,18 @@ TEST_CASE("vmath/ext") {
}
SECTION("matrix look_at") {
look_at_lh(float3(-10.f), float3(0.f), float3(0,-1,0));
look_at_rh(float3(-10.f), float3(0.f), float3(0,-1,0));
(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));
orthographic_lh_zo(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
orthographic_lh_no(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
orthographic_rh_zo(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
orthographic_rh_no(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
(void)orthographic_lh_zo(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
(void)orthographic_lh_no(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
(void)orthographic_rh_zo(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
(void)orthographic_rh_no(0.f, 800.f, 0.f, 640.f, 0.f, 10.f);
perspective_lh_zo(1.f, 1.3f, 0.f, 10.f);
perspective_lh_no(1.f, 1.3f, 0.f, 10.f);
perspective_rh_zo(1.f, 1.3f, 0.f, 10.f);
perspective_rh_no(1.f, 1.3f, 0.f, 10.f);
(void)perspective_lh_zo(1.f, 1.3f, 0.f, 10.f);
(void)perspective_lh_no(1.f, 1.3f, 0.f, 10.f);
(void)perspective_rh_zo(1.f, 1.3f, 0.f, 10.f);
(void)perspective_rh_no(1.f, 1.3f, 0.f, 10.f);
}
SECTION("vector angle") {