tests
This commit is contained in:
parent
94215f8305
commit
38d628d4ef
7
source/hpr/tests/main.cpp
Normal file
7
source/hpr/tests/main.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
@ -1,7 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
|
||||||
#include <hpr/container/static_array.hpp>
|
#include <hpr/container/static_array.hpp>
|
||||||
|
#include <hpr/container/dynamic_array.hpp>
|
||||||
|
#include <hpr/container/tree_node.hpp>
|
||||||
|
|
||||||
|
|
||||||
TEST(containers, StaticArray)
|
TEST(containers, StaticArray)
|
||||||
{
|
{
|
||||||
@ -21,8 +25,6 @@ TEST(containers, StaticArray)
|
|||||||
EXPECT_EQ(sarr[3], 5);
|
EXPECT_EQ(sarr[3], 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <hpr/container/dynamic_array.hpp>
|
|
||||||
|
|
||||||
TEST(containers, DynamicArray)
|
TEST(containers, DynamicArray)
|
||||||
{
|
{
|
||||||
hpr::DynamicArray<float> arr {1, 3, 2};
|
hpr::DynamicArray<float> arr {1, 3, 2};
|
||||||
@ -71,8 +73,6 @@ TEST(containers, DynamicArray)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <hpr/container/tree_node.hpp>
|
|
||||||
|
|
||||||
TEST(containers, TreeNode)
|
TEST(containers, TreeNode)
|
||||||
{
|
{
|
||||||
hpr::TreeNode<float> node1 (5);
|
hpr::TreeNode<float> node1 (5);
|
||||||
@ -92,9 +92,3 @@ TEST(containers, TreeNode)
|
|||||||
EXPECT_EQ(tr3.size(), 2); // node1 has changed ancestor
|
EXPECT_EQ(tr3.size(), 2); // node1 has changed ancestor
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
testing::InitGoogleTest(&argc, argv);
|
|
||||||
return RUN_ALL_TESTS();
|
|
||||||
}
|
|
@ -1,3 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <hpr/math/vector.hpp>
|
#include <hpr/math/vector.hpp>
|
||||||
@ -49,6 +51,7 @@ TEST(math, Matrix)
|
|||||||
EXPECT_EQ(inv(m6), hpr::mat2(4, -1, -7, 2));
|
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(det(hpr::mat3(1, 0, 0, 0, 1, 0, 0, 0, 1)), 1.);
|
||||||
//EXPECT_EQ(m4.det(), 0);
|
//EXPECT_EQ(m4.det(), 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(math, Quaternion)
|
TEST(math, Quaternion)
|
||||||
@ -58,9 +61,3 @@ TEST(math, Quaternion)
|
|||||||
EXPECT_TRUE(hpr::all(hpr::equal(np, hpr::vec3(0, 0, 1))));
|
EXPECT_TRUE(hpr::all(hpr::equal(np, hpr::vec3(0, 0, 1))));
|
||||||
EXPECT_EQ(hpr::norm(hpr::quat(np)), 1);
|
EXPECT_EQ(hpr::norm(hpr::quat(np)), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
testing::InitGoogleTest(&argc, argv);
|
|
||||||
return RUN_ALL_TESTS();
|
|
||||||
}
|
|
@ -1,10 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <hpr/numeric.hpp>
|
#include <hpr/numeric.hpp>
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
|
||||||
|
|
||||||
TEST(math, Scalar)
|
TEST(numeric, Scalar)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(hpr::scalar(5) + hpr::scalar(7), hpr::scalar(12));
|
EXPECT_EQ(hpr::scalar(5) + hpr::scalar(7), hpr::scalar(12));
|
||||||
#ifdef HPR_SCALAR_IMPLEMENTATION
|
#ifdef HPR_SCALAR_IMPLEMENTATION
|
||||||
@ -36,10 +37,5 @@ TEST(math, Scalar)
|
|||||||
EXPECT_EQ(hpr::clip(7., 5, 10), 7);
|
EXPECT_EQ(hpr::clip(7., 5, 10), 7);
|
||||||
EXPECT_EQ(hpr::clip(1., 5, 10), 5);
|
EXPECT_EQ(hpr::clip(1., 5, 10), 5);
|
||||||
EXPECT_EQ(hpr::clip(72., 5, 10), 10);
|
EXPECT_EQ(hpr::clip(72., 5, 10), 10);
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
}
|
||||||
{
|
|
||||||
testing::InitGoogleTest(&argc, argv);
|
|
||||||
return RUN_ALL_TESTS();
|
|
||||||
}
|
|
||||||
|
@ -35,23 +35,38 @@ target("hpr")
|
|||||||
target_end()
|
target_end()
|
||||||
|
|
||||||
|
|
||||||
for _, file in ipairs(os.files("tests/test_*.cpp")) do
|
|
||||||
local name = path.basename(file)
|
|
||||||
target(name)
|
|
||||||
set_kind("binary")
|
|
||||||
set_default(false)
|
|
||||||
set_languages("c++20")
|
|
||||||
|
|
||||||
set_policy("build.c++.modules", false)
|
target("tests")
|
||||||
|
set_kind("binary")
|
||||||
|
set_default(false)
|
||||||
|
set_languages("c++20")
|
||||||
|
|
||||||
add_options("scalar", "scalar_implementation")
|
if is_plat("mingw") or is_plat("windows") then
|
||||||
|
add_ldflags("-static", { force = true} )
|
||||||
|
end
|
||||||
|
|
||||||
add_packages("gtest")
|
set_policy("build.c++.modules", false)
|
||||||
|
|
||||||
add_includedirs("..", { public = true })
|
add_options("scalar", "scalar_implementation")
|
||||||
|
|
||||||
add_files(file)
|
add_packages("gtest")
|
||||||
|
|
||||||
|
add_includedirs("..", { public = true })
|
||||||
|
|
||||||
|
add_files("tests/main.cpp")
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
add_tests("default")
|
|
||||||
target_end()
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user