Skip to content

Commit

Permalink
Cleanup test tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
saraedum committed Sep 12, 2022
1 parent 02b8945 commit c398eda
Show file tree
Hide file tree
Showing 26 changed files with 354 additions and 744 deletions.
2 changes: 1 addition & 1 deletion libflatsurf/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ check_PROGRAMS = main

TESTS = libflatsurf.test.sh

main_SOURCES = main.cc approximation.test.cc bound.test.cc cereal.test.cc chain.test.cc contour_decomposition.test.cc deformation.test.cc edge.test.cc flat_triangulation.test.cc flat_triangulation_collapsed.test.cc flat_triangulation_combinatorial.test.cc flow_decomposition.test.cc half_edge.test.cc interval_exchange_transformation.test.cc parabolic.test.cc path.test.cc permutation.test.cc point.test.cc quadratic_polynomial.test.cc saddle_connections.test.cc saddle_connection.test.cc vector_exactreal.test.cc vector_longlong.test.cc vector.test.cc vertex.test.cc
main_SOURCES = main.cc approximation.test.cc bound.test.cc chain.test.cc contour_decomposition.test.cc deformation.test.cc edge.test.cc flat_triangulation.test.cc flat_triangulation_collapsed.test.cc flat_triangulation_combinatorial.test.cc flow_decomposition.test.cc half_edge.test.cc interval_exchange_transformation.test.cc path.test.cc permutation.test.cc point.test.cc quadratic_polynomial.test.cc saddle_connections.test.cc saddle_connection.test.cc vector_longlong.test.cc vector.test.cc vertex.test.cc vertical.test.cc

noinst_HEADERS = \
surfaces.hpp \
Expand Down
4 changes: 2 additions & 2 deletions libflatsurf/test/approximation.test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of flatsurf.
*
* Copyright (C) 2020 Julian Rüth
* Copyright (C) 2020-2022 Julian Rüth
*
* Flatsurf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -23,7 +23,7 @@

namespace flatsurf::test {

TEMPLATE_TEST_CASE("Approximation", "[arb]", LIBFLATSURF_TEST_REAL_TYPES) {
TEMPLATE_TEST_CASE("Approximation", "[Approximation][arb]", LIBFLATSURF_TEST_REAL_TYPES) {
using T = TestType;
using Arb = exactreal::Arb;
using Arf = exactreal::Arf;
Expand Down
10 changes: 7 additions & 3 deletions libflatsurf/test/bound.test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of flatsurf.
*
* Copyright (C) 2020 Julian Rüth
* Copyright (C) 2020-2022 Julian Rüth
*
* Flatsurf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -18,11 +18,11 @@
*********************************************************************/

#include "../flatsurf/bound.hpp"
#include "external/catch2/single_include/catch2/catch.hpp"
#include "cereal.helpers.hpp"

namespace flatsurf::test {

TEST_CASE("Bound Arithmetic", "[bound]") {
TEST_CASE("Bound Arithmetic", "[Bound][constructor][operator<][operator>][operator<=][operator>=][operator==]") {
REQUIRE(Bound() < Bound(1));

SECTION("Multiplication works as expected") {
Expand All @@ -43,4 +43,8 @@ TEST_CASE("Bound Arithmetic", "[bound]") {
}
}

TEST_CASE("Serialization of a Bound", "[Bound][save][load]") {
testRoundtrip(Bound(13, 37));
}

} // namespace flatsurf::test
38 changes: 35 additions & 3 deletions libflatsurf/test/cereal.helpers.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**********************************************************************
* This file is part of flatsurf.
*
* Copyright (C) 2019 Vincent Delecroix
* Copyright (C) 2019 Julian Rüth
* Copyright (C) 2019 Vincent Delecroix
* Copyright (C) 2019-2022 Julian Rüth
*
* Flatsurf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -28,7 +28,10 @@
#include "../flatsurf/edge.hpp"
#include "../flatsurf/half_edge.hpp"
#include "../flatsurf/vertex.hpp"
#include "./surfaces.hpp"
#include "../flatsurf/cereal.hpp"
#include "surfaces.hpp"
#include "external/cereal/include/cereal/archives/json.hpp"
#include "external/catch2/single_include/catch2/catch.hpp"

namespace flatsurf::test {

Expand Down Expand Up @@ -128,6 +131,35 @@ struct comparer<flatsurf::Vertical<Surface>> {
}
};

template <typename T>
static void testRoundtrip(const T& x) {
using cereal::JSONInputArchive;
using cereal::JSONOutputArchive;

CAPTURE(printer<T>::toString(x));

std::stringstream s;

{
JSONOutputArchive archive(s);
archive(cereal::make_nvp("test", x));
}

INFO("Serialized to " << s.str());

auto y = factory<T>::make();

{
JSONInputArchive archive(s);
archive(cereal::make_nvp("test", *y));
}

CAPTURE(printer<T>::toString(*y));

REQUIRE(comparer<T>::eq(x, *y));
}


} // namespace flatsurf::test

#endif
98 changes: 0 additions & 98 deletions libflatsurf/test/cereal.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,108 +21,10 @@
#include "../flatsurf/cereal.hpp"
#include "../flatsurf/vertical.hpp"
#include "cereal.helpers.hpp"
#include "external/catch2/single_include/catch2/catch.hpp"
#include "external/cereal/include/cereal/archives/json.hpp"
#include "generators/saddle_connection_generator.hpp"
#include "surfaces.hpp"

namespace flatsurf::test {

template <typename T>
static void testRoundtrip(const T& x) {
using cereal::JSONInputArchive;
using cereal::JSONOutputArchive;

CAPTURE(printer<T>::toString(x));

std::stringstream s;

{
JSONOutputArchive archive(s);
archive(cereal::make_nvp("test", x));
}

INFO("Serialized to " << s.str());

auto y = factory<T>::make();

{
JSONInputArchive archive(s);
archive(cereal::make_nvp("test", *y));
}

CAPTURE(printer<T>::toString(*y));

REQUIRE(comparer<T>::eq(x, *y));
}

TEST_CASE("Serialization of a HalfEdge", "[cereal]") {
testRoundtrip(HalfEdge(1337));
}

TEST_CASE("Serialization of an Edge", "[cereal]") {
testRoundtrip(Edge(1337));
}

TEST_CASE("Serialization of a Vertex", "[cereal]") {
auto square = makeSquare<Vector<long long>>();
testRoundtrip(square->vertices()[0]);
}

TEMPLATE_TEST_CASE("Serialization of a Vector", "[cereal]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using R2 = Vector<TestType>;
auto square = makeSquare<R2>();

for (auto halfEdge : square->halfEdges()) {
testRoundtrip(square->fromHalfEdge(halfEdge));
testRoundtrip(square->fromHalfEdgeApproximate(HalfEdge(1)));
}
}

TEST_CASE("Serialization of a FlatTriangulationCombinatorial", "[cereal]") {
auto square = makeSquareCombinatorial();

testRoundtrip(*square);
}

TEMPLATE_TEST_CASE("Serialization of a FlatTriangulation", "[cereal]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using R2 = Vector<TestType>;
auto square = makeSquare<R2>();

testRoundtrip(*square);
}

TEMPLATE_TEST_CASE("Serialization of a Vertical", "[cereal]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using R2 = Vector<TestType>;
auto square = makeSquare<R2>();

testRoundtrip(Vertical(*square, square->fromHalfEdge(HalfEdge(1))));
}

TEMPLATE_TEST_CASE("Serialization of a Chain", "[cereal]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using R2 = Vector<TestType>;
auto square = makeSquare<R2>();

testRoundtrip(Chain(*square, HalfEdge(1)));
}

TEMPLATE_TEST_CASE("Serialization of a SaddleConnection", "[cereal]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using T = TestType;
using R2 = Vector<T>;
auto square = makeSquare<R2>();

const auto saddleConnection = GENERATE_COPY(saddleConnections<T>(square));
testRoundtrip(saddleConnection);
}

TEST_CASE("Serialization of a Bound", "[cereal]") {
testRoundtrip(Bound(13, 37));
}

TEST_CASE("Serialization of a Permutation", "[cereal]") {
Permutation<HalfEdge> p({{HalfEdge(1), HalfEdge(2), HalfEdge(-1)}, {HalfEdge(-2)}});

testRoundtrip(p);
}

} // namespace flatsurf::test
13 changes: 10 additions & 3 deletions libflatsurf/test/chain.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file is part of flatsurf.
*
* Copyright (C) 2019-2020 Vincent Delecroix
* Copyright (C) 2019-2020 Julian Rüth
* Copyright (C) 2019-2022 Julian Rüth
*
* Flatsurf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -21,11 +21,11 @@
#include "../flatsurf/chain.hpp"
#include "../flatsurf/flat_triangulation.hpp"
#include "../flatsurf/half_edge.hpp"
#include "external/catch2/single_include/catch2/catch.hpp"
#include "cereal.helpers.hpp"
#include "surfaces.hpp"

namespace flatsurf::test {
TEMPLATE_TEST_CASE("Chain Arithmetic", "[chain][arithmetic]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
TEMPLATE_TEST_CASE("Chain Arithmetic", "[Chain][operator+=][operator+][operator-][operator==][operator!=]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
using R2 = Vector<TestType>;
auto square = makeSquare<R2>();

Expand Down Expand Up @@ -57,4 +57,11 @@ TEMPLATE_TEST_CASE("Chain Arithmetic", "[chain][arithmetic]", (long long), (mpz_
}
}

TEMPLATE_TEST_CASE("Serialization of a Chain", "[Chain][save][load]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using R2 = Vector<TestType>;
auto square = makeSquare<R2>();

testRoundtrip(Chain(*square, HalfEdge(1)));
}

} // namespace flatsurf::test
4 changes: 2 additions & 2 deletions libflatsurf/test/contour_decomposition.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace flatsurf::test {

using namespace flatsurf;

TEST_CASE("Perimeter of Contour Decomposition", "[contour_decomposition][perimeter]") {
TEST_CASE("Perimeter of Contour Decomposition", "[ContourDecomposition][perimeter]") {
SECTION("A Trivial Case") {
using T = long long;
using R2 = Vector<T>;
Expand Down Expand Up @@ -95,7 +95,7 @@ TEST_CASE("Perimeter of Contour Decomposition", "[contour_decomposition][perimet
};
}

TEMPLATE_TEST_CASE("Connections and IET from Contour Decomposition", "[contour_decomposition][iet]", (long long), (mpz_class), (mpq_class), (eantic::renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
TEMPLATE_TEST_CASE("Connections and IET from Contour Decomposition", "[ContourDecomposition][iet]", (long long), (mpz_class), (mpq_class), (eantic::renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using T = TestType;

const auto surface = GENERATE_SURFACES(T);
Expand Down
8 changes: 4 additions & 4 deletions libflatsurf/test/deformation.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace flatsurf::test {

TEMPLATE_TEST_CASE("Deformations", "[deformation]", (long long), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
TEMPLATE_TEST_CASE("Deformations", "[Deformation]", (long long), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
using T = TestType;

const auto surface = GENERATE_SURFACES(T);
Expand Down Expand Up @@ -68,7 +68,7 @@ TEMPLATE_TEST_CASE("Deformations", "[deformation]", (long long), (mpq_class), (r
}
}

TEMPLATE_TEST_CASE("Mapping Points Across Deformations", "[deformation][point]", (long long), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
TEMPLATE_TEST_CASE("Mapping Points Across Deformations", "[Deformation][operator()]", (long long), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
using T = TestType;
using Surface = FlatTriangulation<T>;

Expand Down Expand Up @@ -104,7 +104,7 @@ TEMPLATE_TEST_CASE("Mapping Points Across Deformations", "[deformation][point]",
}
}

TEMPLATE_TEST_CASE("Mapping Paths Across Deformation", "[deformation][path]", (long long), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
TEMPLATE_TEST_CASE("Mapping Paths Across Deformation", "[Deformation][operator()]", (long long), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::NumberField>)) {
using T = TestType;
using Surface = FlatTriangulation<T>;

Expand Down Expand Up @@ -142,7 +142,7 @@ TEMPLATE_TEST_CASE("Mapping Paths Across Deformation", "[deformation][path]", (l
}
}

TEMPLATE_TEST_CASE("Deform a Flat Triangulation", "[flat_triangulation][deformation]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
TEMPLATE_TEST_CASE("Deform a Flat Triangulation", "[Deformation]", (long long), (mpz_class), (mpq_class), (renf_elem_class), (exactreal::Element<exactreal::IntegerRing>), (exactreal::Element<exactreal::RationalField>), (exactreal::Element<exactreal::NumberField>)) {
using T = TestType;
using R2 = Vector<T>;

Expand Down
12 changes: 8 additions & 4 deletions libflatsurf/test/edge.test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**********************************************************************
* This file is part of flatsurf.
*
* Copyright (C) 2020 Vincent Delecroix
* Copyright (C) 2020 Julian Rüth
* Copyright (C) 2020 Vincent Delecroix
* Copyright (C) 2020-2022 Julian Rüth
*
* Flatsurf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -20,11 +20,11 @@

#include "../flatsurf/edge.hpp"
#include "../flatsurf/half_edge.hpp"
#include "external/catch2/single_include/catch2/catch.hpp"
#include "cereal.helpers.hpp"

namespace flatsurf::test {

TEST_CASE("Edge Basics", "[edge]") {
TEST_CASE("Edge Basics", "[Edge][constructor][operator==][fromIndxe]") {
const int id = GENERATE(range(1, 1024));

const Edge e(id);
Expand All @@ -37,4 +37,8 @@ TEST_CASE("Edge Basics", "[edge]") {
REQUIRE(Edge::fromIndex(e.index()) == e);
}

TEST_CASE("Serialization of an Edge", "[Edge][load_minimal][save_minimal]") {
testRoundtrip(Edge(1337));
}

} // namespace flatsurf::test

0 comments on commit c398eda

Please sign in to comment.