13#include <doctest/doctest.h>
16using namespace manifolds;
18SCENARIO(
"MoveStrategy<MOVE_ALWAYS> special member and swap properties" *
19 doctest::test_suite(
"move_always"))
22 "MoveStrategy<MOVE_ALWAYS> special member and swap properties.\n");
23 GIVEN(
"A Move always move strategy.")
25 WHEN(
"Special members are examined.")
27 THEN(
"It is no-throw destructible.")
29 REQUIRE(is_nothrow_destructible_v<MoveAlways_3>);
30 REQUIRE(is_nothrow_destructible_v<MoveAlways_4>);
31 spdlog::debug(
"It is no-throw destructible.\n");
33 THEN(
"It is no-throw default constructible.")
35 REQUIRE(is_nothrow_default_constructible_v<MoveAlways_3>);
36 REQUIRE(is_nothrow_default_constructible_v<MoveAlways_4>);
37 spdlog::debug(
"It is no-throw default constructible.\n");
39 THEN(
"It is no-throw copy constructible.")
41 REQUIRE(is_nothrow_copy_constructible_v<MoveAlways_3>);
42 REQUIRE(is_nothrow_copy_constructible_v<MoveAlways_4>);
43 spdlog::debug(
"It is no-throw copy constructible.\n");
45 THEN(
"It is no-throw copy assignable.")
47 REQUIRE(is_nothrow_copy_assignable_v<MoveAlways_3>);
48 REQUIRE(is_nothrow_copy_assignable_v<MoveAlways_4>);
49 spdlog::debug(
"It is no-throw copy assignable.\n");
51 THEN(
"It is no-throw move constructible.")
53 REQUIRE(is_nothrow_move_constructible_v<MoveAlways_3>);
54 REQUIRE(is_nothrow_move_constructible_v<MoveAlways_4>);
55 spdlog::debug(
"It is no-throw move constructible.\n");
57 THEN(
"It is no-throw move assignable.")
59 REQUIRE(is_nothrow_move_assignable_v<MoveAlways_3>);
60 REQUIRE(is_nothrow_move_assignable_v<MoveAlways_4>);
61 spdlog::debug(
"It is no-throw move assignable.\n");
63 THEN(
"It is no-throw swappable.")
65 REQUIRE(is_nothrow_swappable_v<MoveAlways_3>);
66 REQUIRE(is_nothrow_swappable_v<MoveAlways_4>);
67 spdlog::debug(
"It is no-throw swappable.\n");
69 THEN(
"It is constructible from 2 parameters.")
71 REQUIRE(is_constructible_v<MoveAlways_3, Int_precision, Int_precision>);
72 REQUIRE(is_constructible_v<MoveAlways_4, Int_precision, Int_precision>);
73 spdlog::debug(
"It is constructible from 2 parameters.\n");
79SCENARIO(
"MoveAlways member functions" * doctest::test_suite(
"move_always"))
81 spdlog::debug(
"MoveAlways member functions.\n");
82 GIVEN(
"A correctly-constructed Manifold_3.")
84 auto constexpr simplices = 640;
85 auto constexpr timeslices = 4;
86 Manifold_3 const manifold(simplices, timeslices);
87 REQUIRE(manifold.is_correct());
88 WHEN(
"A MoveAlways_3 is constructed.")
90 auto constexpr passes = 10;
91 auto constexpr checkpoint = 5;
93 THEN(
"The correct passes and checkpoints are instantiated.")
95 CHECK_EQ(mover.passes(), passes);
96 CHECK_EQ(mover.checkpoint(), checkpoint);
98 THEN(
"Attempted, successful, and failed moves are zero-initialized.")
100 CHECK_EQ(mover.get_attempted().total(), 0);
101 CHECK_EQ(mover.get_succeeded().total(), 0);
102 CHECK_EQ(mover.get_failed().total(), 0);
105 WHEN(
"A MoveAlways_3 algorithm is instantiated.")
107 auto constexpr passes = 1;
108 auto constexpr checkpoint = 1;
110 THEN(
"The correct passes and checkpoints are instantiated.")
112 CHECK_EQ(mover.passes(), passes);
113 CHECK_EQ(mover.checkpoint(), checkpoint);
115 THEN(
"Attempted moves and successful moves are zero-initialized.")
117 CHECK_EQ(mover.get_attempted().total(), 0);
118 CHECK_EQ(mover.get_succeeded().total(), 0);
119 CHECK_EQ(mover.get_failed().total(), 0);
127SCENARIO(
"Using the MoveAlways algorithm" * doctest::test_suite(
"move_always") *
130 spdlog::debug(
"Using the MoveAlways algorithm.\n");
131 GIVEN(
"A correctly-constructed Manifold_3.")
133 auto constexpr simplices = 64;
134 auto constexpr timeslices = 3;
135 Manifold_3 const manifold(simplices, timeslices);
136 REQUIRE(manifold.is_correct());
137 WHEN(
"A MoveAlways_3 algorithm is used.")
139 auto constexpr passes = 1;
140 auto constexpr checkpoint = 1;
142 THEN(
"A lot of moves are made.")
144 auto result = mover(manifold);
146 CHECK(result.is_valid());
148 "The correct number of attempted, successful, and failed moves are "
151 CHECK_EQ(mover.get_attempted().total(),
152 mover.get_succeeded().total() + mover.get_failed().total());
154 mover.print_results();
159 GIVEN(
"A 4D manifold.")
161 WHEN(
"A MoveStrategy4 is constructed.")
163 auto constexpr passes = 1;
164 auto constexpr checkpoint = 1;
166 THEN(
"The correct passes and checkpoints are instantiated.")
168 CHECK_EQ(mover.passes(), passes);
169 CHECK_EQ(mover.checkpoint(), checkpoint);
171 THEN(
"Attempted moves and successful moves are zero-initialized.")
173 CHECK_EQ(mover.get_attempted().two_four_moves(), 0);
174 CHECK_EQ(mover.get_failed().two_four_moves(), 0);
Randomly selects moves to always perform on triangulations.
SCENARIO("Perform bistellar flip on Delaunay triangulation" *doctest::test_suite("bistellar"))