Commit c7fad852 authored by Philip Trettner's avatar Philip Trettner

replaced googletest by doctest

parent 55070ef3
......@@ -4,9 +4,9 @@
[submodule "extern/polymesh"]
path = extern/polymesh
url = https://www.graphics.rwth-aachen.de:9000/ptrettner/polymesh.git
[submodule "extern/googletest"]
path = extern/googletest
url = https://github.com/google/googletest.git
[submodule "extern/glm"]
path = extern/glm
url = https://github.com/g-truc/glm.git
[submodule "extern/doctest"]
path = extern/doctest
url = https://github.com/onqtam/doctest.git
......@@ -9,7 +9,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) # required by some dependencies (e.g. gtest)
option(PM_BUILD_TESTS "Build polymesh tests" OFF)
......@@ -96,8 +95,10 @@ endforeach()
if (PM_BUILD_TESTS)
# google test library
add_subdirectory(extern/googletest/googletest)
# doctest test library
option(DOCTEST_WITH_TESTS "" OFF)
option(DOCTEST_WITH_MAIN_IN_STATIC_LIB "" OFF)
add_subdirectory(extern/doctest)
file(GLOB_RECURSE SOURCES
"tests/*.cc"
......@@ -111,7 +112,7 @@ if (PM_BUILD_TESTS)
target_link_libraries(pm-tests PUBLIC
typed-geometry
polymesh
gtest
doctest
)
target_include_directories(pm-tests PUBLIC "tests")
......@@ -124,9 +125,7 @@ endif()
# ===============================================
# Folder grouping
foreach(TARGET_NAME
gtest
gtest_main
foreach(TARGET_NAME
polymesh
typed-geometry-src
)
......
Subproject commit b2611a140fe67d983b7078a3d3cf76a79efaaa9b
Subproject commit 9a502a5b14b4a6160103c1f2c64331772878d86a
Subproject commit a5727bc4cda9e456e4991f519f3edfeec8f9a35e
Subproject commit 72186178337fe72248d2007d729c54c274982762
Subproject commit 04a2587d59cd5a142ed9bdc95c2d7933d8ccc879
Subproject commit 80d6f1a5969edd30bf11e569e62dab8ba3c6b9d2
#include <gtest/gtest.h>
#include <doctest/doctest.h>
#include <polymesh/Mesh.hh>
#include <polymesh/algorithms/remeshing/delaunay.hh>
......@@ -10,7 +10,7 @@
#include <tg/typed-geometry.hh>
TEST(Algorithms, Delaunay)
TEST_CASE("Algorithms.Delaunay")
{
pm::Mesh m;
auto pos = attribute(m.vertices(), glm::vec3{});
......
This diff is collapsed.
#include <gtest/gtest.h>
#include <doctest/doctest.h>
#include <polymesh/Mesh.hh>
TEST(Interface, Handles)
TEST_CASE("Interface.Handles")
{
pm::Mesh m;
......@@ -22,15 +22,15 @@ TEST(Interface, Handles)
auto k1 = m[pm::vertex_index(1)];
auto k2 = m[pm::vertex_index(2)];
ASSERT_EQ(v0, i0);
ASSERT_EQ(v1, i1);
ASSERT_EQ(v2, i2);
CHECK(v0 == i0);
CHECK(v1 == i1);
CHECK(v2 == i2);
ASSERT_EQ(v0, j0);
ASSERT_EQ(v1, j1);
ASSERT_EQ(v2, j2);
CHECK(v0 == j0);
CHECK(v1 == j1);
CHECK(v2 == j2);
ASSERT_EQ(v0, k0);
ASSERT_EQ(v1, k1);
ASSERT_EQ(v2, k2);
CHECK(v0 == k0);
CHECK(v1 == k1);
CHECK(v2 == k2);
}
#include <gtest/gtest.h>
#define DOCTEST_CONFIG_IMPLEMENT
#include <doctest/doctest.h>
int main(int argc, char **argv)
{
std::vector<char const *> args;
for (auto i = 0; i < argc; ++i)
args.push_back(argv[i]);
args.push_back("--gtest_break_on_failure");
args.push_back("--gtest_catch_exceptions=0");
argc = (int)args.size();
doctest::Context context;
context.applyCommandLine(argc, argv);
testing::InitGoogleTest(&argc, (char **)args.data());
auto res = RUN_ALL_TESTS();
auto res = context.run();
return res;
}
#include <gtest/gtest.h>
#include <doctest/doctest.h>
#include <glm/glm.hpp>
#include <tg/typed-geometry-std.hh>
......@@ -14,30 +14,30 @@ template <class Pos3>
void test_cube(pm::Mesh const& m, pm::vertex_attribute<Pos3> const& pos)
{
// topological
ASSERT_EQ(m.vertices().size(), 8);
ASSERT_EQ(m.faces().size(), 6);
ASSERT_EQ(m.edges().size(), 4 * 3);
ASSERT_EQ(m.halfedges().size(), 4 * 3 * 2);
CHECK(m.vertices().size() == 8);
CHECK(m.faces().size() == 6);
CHECK(m.edges().size() == 4 * 3);
CHECK(m.halfedges().size() == 4 * 3 * 2);
ASSERT_FALSE(is_triangle_mesh(m));
ASSERT_TRUE(is_quad_mesh(m));
CHECK(!is_triangle_mesh(m));
CHECK(is_quad_mesh(m));
for (auto f : m.faces())
ASSERT_EQ(f.vertices().size(), 4);
CHECK(f.vertices().size() == 4);
for (auto v : m.vertices())
{
ASSERT_EQ(v.faces().size(), 3);
ASSERT_EQ(valence(v), 3);
CHECK(v.faces().size() == 3);
CHECK(valence(v) == 3);
}
ASSERT_TRUE(is_closed_mesh(m));
ASSERT_EQ(euler_characteristic(m), 2);
CHECK(is_closed_mesh(m));
CHECK(euler_characteristic(m) == 2);
int v_comps;
int f_comps;
vertex_components(m, &v_comps);
face_components(m, &f_comps);
ASSERT_EQ(v_comps, 1);
ASSERT_EQ(f_comps, 1);
CHECK(v_comps == 1);
CHECK(f_comps == 1);
// attributes
auto vnormals = vertex_normals_by_area(m, pos);
......@@ -61,12 +61,12 @@ void test_cube(pm::Mesh const& m, pm::vertex_attribute<Pos3> const& pos)
if constexpr (std::is_same<Pos3, tg::pos3>::value)
{
ASSERT_EQ(min, min_element(an));
ASSERT_EQ(max, max_element(an));
CHECK(min == min_element(an));
CHECK(max == max_element(an));
}
ASSERT_EQ(min, 0.0f);
ASSERT_EQ(max, 1.0f);
CHECK(min == 0.0f);
CHECK(max == 1.0f);
auto c = face_centroid(f, pos);
auto cntHalf = 0;
......@@ -78,8 +78,8 @@ void test_cube(pm::Mesh const& m, pm::vertex_attribute<Pos3> const& pos)
else if (c[i] == 1.0f || c[i] == 0.0f)
cntFull++;
}
ASSERT_EQ(cntHalf, 2);
ASSERT_EQ(cntFull, 1);
CHECK(cntHalf == 2);
CHECK(cntFull == 1);
}
for (auto h : m.halfedges())
......@@ -89,10 +89,10 @@ void test_cube(pm::Mesh const& m, pm::vertex_attribute<Pos3> const& pos)
auto min = tg::min(ad.x, ad.y, ad.z);
auto max = tg::max(ad.x, ad.y, ad.z);
ASSERT_EQ(min, 0.0f);
ASSERT_EQ(max, 1.0f);
CHECK(min == 0.0f);
CHECK(max == 1.0f);
ASSERT_EQ(edge_length(h, pos), edge_length(h.edge(), pos));
CHECK(edge_length(h, pos) == edge_length(h.edge(), pos));
}
for (auto v : m.vertices())
......@@ -101,27 +101,27 @@ void test_cube(pm::Mesh const& m, pm::vertex_attribute<Pos3> const& pos)
for (auto f : v.faces())
{
ASSERT_TRUE(f.is_valid());
ASSERT_EQ(fareas[f], 1.0f);
CHECK(f.is_valid());
CHECK(fareas[f] == 1.0f);
auto fn = face_normal(f, pos);
ASSERT_GT(dot(vn, fn), 0.0f);
CHECK(dot(vn, fn) > 0.0f);
}
}
for (auto e : m.edges())
{
ASSERT_EQ(edge_lengths[e], 1.0f);
CHECK(edge_lengths[e] == 1.0f);
}
auto [pmin, pmax] = pos.minmax();
ASSERT_EQ(pmin, Pos3(0, 0, 0));
ASSERT_EQ(pmax, Pos3(1, 1, 1));
CHECK(pmin == Pos3(0, 0, 0));
CHECK(pmax == Pos3(1, 1, 1));
}
} // namespace
TEST(Objects, CubePropertiesTG)
TEST_CASE("Objects.CubePropertiesTG")
{
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
......@@ -134,10 +134,10 @@ TEST(Objects, CubePropertiesTG)
test_cube(m, pos);
auto ll = low_level_api(m);
ASSERT_EQ(ll.vertex_attribute_count(), 1);
ASSERT_EQ(ll.edge_attribute_count(), 0);
ASSERT_EQ(ll.face_attribute_count(), 0);
ASSERT_EQ(ll.halfedge_attribute_count(), 0);
CHECK(ll.vertex_attribute_count() == 1);
CHECK(ll.edge_attribute_count() == 0);
CHECK(ll.face_attribute_count() == 0);
CHECK(ll.halfedge_attribute_count() == 0);
m.assert_consistency();
......@@ -154,7 +154,7 @@ TEST(Objects, CubePropertiesTG)
}
}
TEST(Objects, CubePropertiesGlm)
TEST_CASE("Objects.CubePropertiesGlm")
{
pm::Mesh m;
auto pos = m.vertices().make_attribute<glm::vec3>();
......
#include <gtest/gtest.h>
#include <doctest/doctest.h>
#include <polymesh/Mesh.hh>
#include <polymesh/algorithms/properties.hh>
......@@ -6,19 +6,19 @@
#include <tg/typed-geometry.hh>
TEST(Ranges, Basics)
TEST_CASE("Ranges.Basics")
{
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
pm::objects::add_cube(m, pos);
ASSERT_EQ(pos.avg(), tg::pos3(0.5f));
ASSERT_EQ(pos.min(), tg::pos3(0));
ASSERT_EQ(pos.max(), tg::pos3(1));
CHECK(pos.avg() == tg::pos3(0.5f));
CHECK(pos.min() == tg::pos3(0));
CHECK(pos.max() == tg::pos3(1));
ASSERT_EQ(m.vertices().avg(pos), tg::pos3(0.5f));
ASSERT_EQ(m.vertices().min(pos), tg::pos3(0));
ASSERT_EQ(m.vertices().max(pos), tg::pos3(1));
CHECK(m.vertices().avg(pos) == tg::pos3(0.5f));
CHECK(m.vertices().min(pos) == tg::pos3(0));
CHECK(m.vertices().max(pos) == tg::pos3(1));
struct face_value
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment