13#include <doctest/doctest.h>
15#include <tl/function_ref.hpp>
20using namespace manifolds;
22SCENARIO(
"Simple Lambda operations" * doctest::test_suite(
"function_ref"))
24 auto constexpr increment_lambda = [](
int a) {
return ++a; };
25 GIVEN(
"A simple lambda.")
27 WHEN(
"Lambda is called with 0.")
29 THEN(
"We should get 1.") { REQUIRE_EQ(increment_lambda(0), 1); }
32 WHEN(
"Lambda is called with 1.")
34 THEN(
"We should get 2.") { REQUIRE_EQ(increment_lambda(1), 2); }
37 WHEN(
"Lambda is called with 5.")
39 THEN(
"We should get 6.") { REQUIRE_EQ(increment_lambda(5), 6); }
44SCENARIO(
"Complex lambda operations" * doctest::test_suite(
"function_ref"))
46 GIVEN(
"A lambda storing a move.")
48 auto constexpr desired_simplices = 640;
49 auto constexpr desired_timeslices = 4;
50 Manifold_3 manifold(desired_simplices, desired_timeslices);
51 REQUIRE(manifold.is_correct());
52 WHEN(
"A lambda is constructed for a move.")
57 THEN(
"Running the lambda makes the move.")
59 auto result = move23(manifold);
61 CHECK(ergodic_moves::check_move(manifold, result,
62 move_tracker::move_type::TWO_THREE));
64 fmt::print(
"Manifold properties:\n");
65 manifold.print_details();
66 fmt::print(
"Moved manifold properties:\n");
67 result.print_details();
73SCENARIO(
"Function_ref operations" * doctest::test_suite(
"function_ref"))
75 GIVEN(
"A simple lambda stored in a function_ref.")
77 auto const increment = [](
int incr) {
return ++incr; };
78 tl::function_ref<int(
int)>
const lambda_ref(increment);
79 WHEN(
"Function_ref is called with 0.")
81 THEN(
"We should get 1.") { REQUIRE_EQ(lambda_ref(1), 2); }
84 GIVEN(
"A function pointer to a move stored in a function_ref.")
86 auto constexpr desired_simplices = 640;
87 auto constexpr desired_timeslices = 4;
88 Manifold_3 manifold(desired_simplices, desired_timeslices);
89 REQUIRE(manifold.is_correct());
90 tl::function_ref
const complex_ref(ergodic_moves::do_23_move);
91 WHEN(
"The function_ref is invoked.")
93 auto result = complex_ref(manifold);
95 THEN(
"The move from the function_ref is correct.")
97 CHECK(ergodic_moves::check_move(manifold, result.value(),
98 move_tracker::move_type::TWO_THREE));
100 fmt::print(
"Manifold properties:\n");
101 manifold.print_details();
102 fmt::print(
"Moved manifold properties:\n");
103 result->print_details();
107 GIVEN(
"A lambda invoking a move stored in a function_ref.")
109 auto constexpr desired_simplices = 640;
110 auto constexpr desired_timeslices = 4;
111 Manifold_3 manifold(desired_simplices, desired_timeslices);
112 REQUIRE(manifold.is_correct());
113 auto const move23 = [](
Manifold_3& t_manifold) {
117 WHEN(
"The function_ref is invoked.")
119 auto result = complex_ref(manifold);
122 "The move stored in the lambda invoked by the function_ref is "
125 CHECK(ergodic_moves::check_move(manifold, result,
126 move_tracker::move_type::TWO_THREE));
128 fmt::print(
"Manifold properties:\n");
129 manifold.print_details();
130 fmt::print(
"Moved manifold properties:\n");
131 result.print_details();
Pachner moves on 2+1 dimensional foliated Delaunay triangulations.
auto do_23_move(Manifold &t_manifold) -> Expected
Perform a (2,3) move.
SCENARIO("Perform bistellar flip on Delaunay triangulation" *doctest::test_suite("bistellar"))