Commit c7fad852 authored by Philip Trettner's avatar Philip Trettner
Browse files

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{});
......
#include <gtest/gtest.h>
#include <doctest/doctest.h>
#include <polymesh/Mesh.hh>
......@@ -47,7 +47,7 @@ static_assert(sizeof(pm::vertex_attribute<bool>)
*/
static_assert(sizeof(pm::Mesh) == 120, "mesh is bigger than expected");
TEST(Attributes, Creation)
TEST_CASE("Attributes.Creation")
{
pm::Mesh m;
......@@ -70,15 +70,15 @@ TEST(Attributes, Creation)
for (auto v : {v0, v1, v2})
{
ASSERT_EQ(a0[v], 0);
ASSERT_EQ(a1[v], 3);
ASSERT_EQ(a2[v], 5);
ASSERT_EQ(a3[v], 7);
ASSERT_EQ(a4[v], 11);
ASSERT_EQ(a5[v], 0);
// ASSERT_EQ(a6[v], 13);
ASSERT_EQ(a7[v], 0);
ASSERT_EQ(a8[v], 15);
CHECK(a0[v] == 0);
CHECK(a1[v] == 3);
CHECK(a2[v] == 5);
CHECK(a3[v] == 7);
CHECK(a4[v] == 11);
CHECK(a5[v] == 0);
// CHECK(a6[v] == 13);
CHECK(a7[v] == 0);
CHECK(a8[v] == 15);
}
}
......@@ -93,15 +93,15 @@ TEST(Attributes, Creation)
auto a7 = pm::attribute<int>(m.faces());
auto a8 = attribute(m.faces(), 15);
ASSERT_EQ(a0[f], 0);
ASSERT_EQ(a1[f], 3);
ASSERT_EQ(a2[f], 5);
ASSERT_EQ(a3[f], 7);
ASSERT_EQ(a4[f], 11);
ASSERT_EQ(a5[f], 0);
// ASSERT_EQ(a6[f], 13);
ASSERT_EQ(a7[f], 0);
ASSERT_EQ(a8[f], 15);
CHECK(a0[f] == 0);
CHECK(a1[f] == 3);
CHECK(a2[f] == 5);
CHECK(a3[f] == 7);
CHECK(a4[f] == 11);
CHECK(a5[f] == 0);
// CHECK(a6[f] == 13);
CHECK(a7[f] == 0);
CHECK(a8[f] == 15);
}
{
......@@ -129,16 +129,16 @@ TEST(Attributes, Creation)
}
}
TEST(Attributes, Registry)
TEST_CASE("Attributes.Registry")
{
pm::Mesh m;
auto ll = low_level_api(m);
auto ASSERT_ATTR_CNT = [&](int v, int f, int e, int h) {
ASSERT_EQ(ll.vertex_attribute_count(), v);
ASSERT_EQ(ll.face_attribute_count(), f);
ASSERT_EQ(ll.edge_attribute_count(), e);
ASSERT_EQ(ll.halfedge_attribute_count(), h);
CHECK(ll.vertex_attribute_count() == v);
CHECK(ll.face_attribute_count() == f);
CHECK(ll.edge_attribute_count() == e);
CHECK(ll.halfedge_attribute_count() == h);
};
ASSERT_ATTR_CNT(0, 0, 0, 0);
......@@ -176,7 +176,7 @@ TEST(Attributes, Registry)
ASSERT_ATTR_CNT(2, 0, 0, 0);
b = std::move(a); // move
ASSERT_FALSE(a.is_valid());
CHECK(!a.is_valid());
ASSERT_ATTR_CNT(1, 0, 0, 0);
......@@ -189,7 +189,7 @@ TEST(Attributes, Registry)
ASSERT_ATTR_CNT(3, 0, 0, 0);
pm::vertex_attribute<int> e(std::move(c)); // move c into e
ASSERT_FALSE(c.is_valid());
CHECK(!c.is_valid());
ASSERT_ATTR_CNT(3, 0, 0, 0);
......@@ -201,7 +201,7 @@ TEST(Attributes, Registry)
ASSERT_ATTR_CNT(0, 0, 0, 0);
}
TEST(Attributes, DefaultSemantic)
TEST_CASE("Attributes.DefaultSemantic")
{
pm::Mesh m;
......@@ -212,83 +212,83 @@ TEST(Attributes, DefaultSemantic)
auto a = m.vertices().make_attribute_with_default(7);
ASSERT_EQ(ll.vertex_attribute_count(), 1);
CHECK(ll.vertex_attribute_count() == 1);
for (auto v : m.vertices())
ASSERT_EQ(a[v], 7);
CHECK(a[v] == 7);
auto b = m.vertices().make_attribute_with_default(9);
ASSERT_EQ(ll.vertex_attribute_count(), 2);
CHECK(ll.vertex_attribute_count() == 2);
for (auto v : m.vertices())
{
ASSERT_EQ(a[v], 7);
ASSERT_EQ(b[v], 9);
CHECK(a[v] == 7);
CHECK(b[v] == 9);
}
b = a;
ASSERT_EQ(ll.vertex_attribute_count(), 2);
CHECK(ll.vertex_attribute_count() == 2);
for (auto v : m.vertices())
{
ASSERT_EQ(a[v], 7);
ASSERT_EQ(b[v], 7);
CHECK(a[v] == 7);
CHECK(b[v] == 7);
}
m.vertices().add();
ASSERT_EQ(ll.vertex_attribute_count(), 2);
CHECK(ll.vertex_attribute_count() == 2);
for (auto v : m.vertices())
{
ASSERT_EQ(a[v], 7);
ASSERT_EQ(b[v], 7);
CHECK(a[v] == 7);
CHECK(b[v] == 7);
}
auto c = b; // copy
auto d = std::move(b); // move
ASSERT_FALSE(b.is_valid());
CHECK(!b.is_valid());
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(a[v], 7);
ASSERT_EQ(c[v], 7);
ASSERT_EQ(d[v], 7);
CHECK(a[v] == 7);
CHECK(c[v] == 7);
CHECK(d[v] == 7);
}
auto e = m.vertices().make_attribute_with_default(11);
auto f = m.vertices().make_attribute_with_default(13);
c = std::move(f);
ASSERT_FALSE(f.is_valid());
CHECK(!f.is_valid());
ASSERT_EQ(ll.vertex_attribute_count(), 4);
CHECK(ll.vertex_attribute_count() == 4);
for (auto v : m.vertices())
{
ASSERT_EQ(a[v], 7);
ASSERT_EQ(c[v], 13);
ASSERT_EQ(d[v], 7);
ASSERT_EQ(e[v], 11);
CHECK(a[v] == 7);
CHECK(c[v] == 13);
CHECK(d[v] == 7);
CHECK(e[v] == 11);
}
e = std::move(a);
ASSERT_FALSE(a.is_valid());
CHECK(!a.is_valid());
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 13);
ASSERT_EQ(d[v], 7);
ASSERT_EQ(e[v], 7);
CHECK(c[v] == 13);
CHECK(d[v] == 7);
CHECK(e[v] == 7);
}
for (auto i = 0; i < 100; ++i)
m.vertices().add();
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 13);
ASSERT_EQ(d[v], 7);
ASSERT_EQ(e[v], 7);
CHECK(c[v] == 13);
CHECK(d[v] == 7);
CHECK(e[v] == 7);
}
{
......@@ -298,24 +298,24 @@ TEST(Attributes, DefaultSemantic)
m.vertices().add();
m.vertices().add();
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 13);
ASSERT_EQ(d[v], 7);
ASSERT_EQ(e[v], 7);
CHECK(c[v] == 13);
CHECK(d[v] == 7);
CHECK(e[v] == 7);
}
c.clear(1);
d.clear(2);
e.clear(3);
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 1);
ASSERT_EQ(d[v], 2);
ASSERT_EQ(e[v], 3);
CHECK(c[v] == 1);
CHECK(d[v] == 2);
CHECK(e[v] == 3);
}
}
......@@ -326,46 +326,46 @@ TEST(Attributes, DefaultSemantic)
m.vertices().add();
m.vertices().add();
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 13);
ASSERT_EQ(d[v], 7);
ASSERT_EQ(e[v], 7);
CHECK(c[v] == 13);
CHECK(d[v] == 7);
CHECK(e[v] == 7);
}
c.clear(1);
d.clear(2);
e.clear(3);
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 1);
ASSERT_EQ(d[v], 2);
ASSERT_EQ(e[v], 3);
CHECK(c[v] == 1);
CHECK(d[v] == 2);
CHECK(e[v] == 3);
}
m.shrink_to_fit();
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 1);
ASSERT_EQ(d[v], 2);
ASSERT_EQ(e[v], 3);
CHECK(c[v] == 1);
CHECK(d[v] == 2);
CHECK(e[v] == 3);
}
c.clear(4);
d.clear(5);
e.clear(6);
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 4);
ASSERT_EQ(d[v], 5);
ASSERT_EQ(e[v], 6);
CHECK(c[v] == 4);
CHECK(d[v] == 5);
CHECK(e[v] == 6);
}
}
......@@ -376,29 +376,29 @@ TEST(Attributes, DefaultSemantic)
m.vertices().add();
m.vertices().add();
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 13);
ASSERT_EQ(d[v], 7);
ASSERT_EQ(e[v], 7);
CHECK(c[v] == 13);
CHECK(d[v] == 7);
CHECK(e[v] == 7);
}
c.clear(1);
d.clear(2);
e.clear(3);
ASSERT_EQ(ll.vertex_attribute_count(), 3);
CHECK(ll.vertex_attribute_count() == 3);
for (auto v : m.vertices())
{
ASSERT_EQ(c[v], 1);
ASSERT_EQ(d[v], 2);
ASSERT_EQ(e[v], 3);
CHECK(c[v] == 1);
CHECK(d[v] == 2);
CHECK(e[v] == 3);
}
}
}
TEST(Attributes, DefaultSemanticEdge)
TEST_CASE("Attributes.DefaultSemanticEdge")
{
pm::Mesh m;
......@@ -409,83 +409,83 @@ TEST(Attributes, DefaultSemanticEdge)
auto a = m.edges().make_attribute_with_default(7);
ASSERT_EQ(ll.edge_attribute_count(), 1);
CHECK(ll.edge_attribute_count() == 1);
for (auto e : m.edges())
ASSERT_EQ(a[e], 7);
CHECK(a[e] == 7);
auto b = m.edges().make_attribute_with_default(9);
ASSERT_EQ(ll.edge_attribute_count(), 2);
CHECK(ll.edge_attribute_count() == 2);
for (auto e : m.edges())
{
ASSERT_EQ(a[e], 7);
ASSERT_EQ(b[e], 9);
CHECK(a[e] == 7);
CHECK(b[e] == 9);
}
b = a;
ASSERT_EQ(ll.edge_attribute_count(), 2);
CHECK(ll.edge_attribute_count() == 2);
for (auto e : m.edges())
{
ASSERT_EQ(a[e], 7);
ASSERT_EQ(b[e], 7);
CHECK(a[e] == 7);
CHECK(b[e] == 7);
}
ll.alloc_edge();
ASSERT_EQ(ll.edge_attribute_count(), 2);
CHECK(ll.edge_attribute_count() == 2);
for (auto e : m.edges())
{
ASSERT_EQ(a[e], 7);
ASSERT_EQ(b[e], 7);
CHECK(a[e] == 7);
CHECK(b[e] == 7);
}
auto c = b; // copy
auto d = std::move(b); // move
ASSERT_FALSE(b.is_valid());
CHECK(!b.is_valid());
ASSERT_EQ(ll.edge_attribute_count(), 3);
CHECK(ll.edge_attribute_count() == 3);
for (auto e : m.edges())
{
ASSERT_EQ(a[e], 7);
ASSERT_EQ(c[e], 7);
ASSERT_EQ(d[e], 7);
CHECK(a[e] == 7);
CHECK(c[e] == 7);
CHECK(d[e] == 7);
}
auto e = m.edges().make_attribute_with_default(11);
auto f = m.edges().make_attribute_with_default(13);
c = std::move(f);
ASSERT_FALSE(f.is_valid());
CHECK(!f.is_valid());
ASSERT_EQ(ll.edge_attribute_count(), 4);
CHECK(ll.edge_attribute_count() == 4);
for (auto eh : m.edges())
{
ASSERT_EQ(a[eh], 7);
ASSERT_EQ(c[eh], 13);
ASSERT_EQ(d[eh], 7);
ASSERT_EQ(e[eh], 11);
CHECK(a[eh] == 7);
CHECK(c[eh] == 13);
CHECK(d[eh] == 7);
CHECK(e[eh] == 11);
}
e = std::move(a);
ASSERT_FALSE(a.is_valid());
CHECK(!a.is_valid());
ASSERT_EQ(ll.edge_attribute_count(), 3);
CHECK(ll.edge_attribute_count() == 3);
for (auto eh : m.edges())
{
ASSERT_EQ(c[eh], 13);
ASSERT_EQ(d[eh], 7);
ASSERT_EQ(e[eh], 7);
CHECK(c[eh] == 13);
CHECK(d[eh] == 7);
CHECK(e[eh] == 7);
}
for (auto i = 0; i < 100; ++i)
ll.alloc_edge();
ASSERT_EQ(ll.edge_attribute_count(), 3);
CHECK(ll.edge_attribute_count() == 3);
for (auto eh : m.edges())
{
ASSERT_EQ(c[eh], 13);
ASSERT_EQ(d[eh], 7);
ASSERT_EQ(e[eh], 7);
CHECK(c[eh] == 13);
CHECK(d[eh] == 7);
CHECK(e[eh] == 7);
}
m.clear();
......@@ -494,23 +494,23 @@ TEST(Attributes, DefaultSemanticEdge)
ll.alloc_edge();
ll.alloc_edge();
ASSERT_EQ(ll.edge_attribute_count(), 3);
CHECK(ll.edge_attribute_count() == 3);
for (auto eh : m.edges())
{
ASSERT_EQ(c[eh], 13);
ASSERT_EQ(d[eh], 7);
ASSERT_EQ(e[eh], 7);
CHECK(c[eh] == 13);
CHECK(d[eh] == 7);
CHECK(e[eh] == 7);
}
c.clear(1);
d.clear(2);
e.clear(3);
ASSERT_EQ(ll.edge_attribute_count(), 3);
CHECK(ll.edge_attribute_count() == 3);
for (auto eh : m.edges())
{
ASSERT_EQ(c[eh], 1);
ASSERT_EQ(d[eh], 2);
ASSERT_EQ(e[eh], 3);
CHECK(c[eh] == 1);
CHECK(d[eh] == 2);
CHECK(e[eh] == 3);
}
}
#include <gtest/gtest.h>
#include <doctest/doctest.h>
#include <polymesh/Mesh.hh>
TEST(Interface, Handles)
TEST_CASE("Interface.Handles")
{
pm::Mesh m;