This commit is contained in:
L-Nafaryus 2023-11-21 17:00:17 +05:00
parent 94215f8305
commit 38d628d4ef
5 changed files with 47 additions and 38 deletions

View File

@ -0,0 +1,7 @@
#include <gtest/gtest.h>
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,7 +1,11 @@
#pragma once
#include <gtest/gtest.h>
#include <hpr/container/static_array.hpp>
#include <hpr/container/dynamic_array.hpp>
#include <hpr/container/tree_node.hpp>
TEST(containers, StaticArray)
{
@ -21,8 +25,6 @@ TEST(containers, StaticArray)
EXPECT_EQ(sarr[3], 5);
}
#include <hpr/container/dynamic_array.hpp>
TEST(containers, DynamicArray)
{
hpr::DynamicArray<float> arr {1, 3, 2};
@ -71,8 +73,6 @@ TEST(containers, DynamicArray)
}
#include <hpr/container/tree_node.hpp>
TEST(containers, TreeNode)
{
hpr::TreeNode<float> node1 (5);
@ -92,9 +92,3 @@ TEST(containers, TreeNode)
EXPECT_EQ(tr3.size(), 2); // node1 has changed ancestor
//
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,3 +1,5 @@
#pragma once
#include <gtest/gtest.h>
#include <hpr/math/vector.hpp>
@ -49,6 +51,7 @@ TEST(math, Matrix)
EXPECT_EQ(inv(m6), hpr::mat2(4, -1, -7, 2));
EXPECT_EQ(det(hpr::mat3(1, 0, 0, 0, 1, 0, 0, 0, 1)), 1.);
//EXPECT_EQ(m4.det(), 0);
}
TEST(math, Quaternion)
@ -58,9 +61,3 @@ TEST(math, Quaternion)
EXPECT_TRUE(hpr::all(hpr::equal(np, hpr::vec3(0, 0, 1))));
EXPECT_EQ(hpr::norm(hpr::quat(np)), 1);
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,10 +1,11 @@
#pragma once
#include <gtest/gtest.h>
#include <hpr/numeric.hpp>
#include <complex>
TEST(math, Scalar)
TEST(numeric, Scalar)
{
EXPECT_EQ(hpr::scalar(5) + hpr::scalar(7), hpr::scalar(12));
#ifdef HPR_SCALAR_IMPLEMENTATION
@ -36,10 +37,5 @@ TEST(math, Scalar)
EXPECT_EQ(hpr::clip(7., 5, 10), 7);
EXPECT_EQ(hpr::clip(1., 5, 10), 5);
EXPECT_EQ(hpr::clip(72., 5, 10), 10);
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -35,13 +35,16 @@ target("hpr")
target_end()
for _, file in ipairs(os.files("tests/test_*.cpp")) do
local name = path.basename(file)
target(name)
target("tests")
set_kind("binary")
set_default(false)
set_languages("c++20")
if is_plat("mingw") or is_plat("windows") then
add_ldflags("-static", { force = true} )
end
set_policy("build.c++.modules", false)
add_options("scalar", "scalar_implementation")
@ -50,8 +53,20 @@ for _, file in ipairs(os.files("tests/test_*.cpp")) do
add_includedirs("..", { public = true })
add_files(file)
add_files("tests/main.cpp")
add_tests("default")
target_end()
on_load(function (target)
for _, file in ipairs(os.files("source/hpr/tests/test_*.cpp")) do
target:add("files", file)
for line in io.lines(file) do
local group, name = string.match(line:gsub("%s+", ""), "TEST%a*%((%a+),(%a+)%)")
if group then
target:add("tests", group .. "/" .. name, { group = group, runargs = "--gtest_filter=" .. group .. "." .. name})
end
end
end
end)
target_end()