CDT++
Causal Dynamical Triangulations in C++
Loading...
Searching...
No Matches
Move_always_test.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 Causal Dynamical Triangulations in C++ using CGAL
3
4 Copyright © 2021 Adam Getchell
5 ******************************************************************************/
6
10
11#include "Move_always.hpp"
12
13#include <doctest/doctest.h>
14
15using namespace std;
16using namespace manifolds;
17
18SCENARIO("MoveStrategy<MOVE_ALWAYS> special member and swap properties" *
19 doctest::test_suite("move_always"))
20{
21 spdlog::debug(
22 "MoveStrategy<MOVE_ALWAYS> special member and swap properties.\n");
23 GIVEN("A Move always move strategy.")
24 {
25 WHEN("Special members are examined.")
26 {
27 THEN("It is no-throw destructible.")
28 {
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");
32 }
33 THEN("It is no-throw default constructible.")
34 {
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");
38 }
39 THEN("It is no-throw copy constructible.")
40 {
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");
44 }
45 THEN("It is no-throw copy assignable.")
46 {
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");
50 }
51 THEN("It is no-throw move constructible.")
52 {
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");
56 }
57 THEN("It is no-throw move assignable.")
58 {
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");
62 }
63 THEN("It is no-throw swappable.")
64 {
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");
68 }
69 THEN("It is constructible from 2 parameters.")
70 {
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");
74 }
75 }
76 }
77}
78
79SCENARIO("MoveAlways member functions" * doctest::test_suite("move_always"))
80{
81 spdlog::debug("MoveAlways member functions.\n");
82 GIVEN("A correctly-constructed Manifold_3.")
83 {
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.")
89 {
90 auto constexpr passes = 10;
91 auto constexpr checkpoint = 5;
92 MoveAlways_3 const mover(passes, checkpoint);
93 THEN("The correct passes and checkpoints are instantiated.")
94 {
95 CHECK_EQ(mover.passes(), passes);
96 CHECK_EQ(mover.checkpoint(), checkpoint);
97 }
98 THEN("Attempted, successful, and failed moves are zero-initialized.")
99 {
100 CHECK_EQ(mover.get_attempted().total(), 0);
101 CHECK_EQ(mover.get_succeeded().total(), 0);
102 CHECK_EQ(mover.get_failed().total(), 0);
103 }
104 }
105 WHEN("A MoveAlways_3 algorithm is instantiated.")
106 {
107 auto constexpr passes = 1;
108 auto constexpr checkpoint = 1;
109 MoveAlways_3 const mover(passes, checkpoint);
110 THEN("The correct passes and checkpoints are instantiated.")
111 {
112 CHECK_EQ(mover.passes(), passes);
113 CHECK_EQ(mover.checkpoint(), checkpoint);
114 }
115 THEN("Attempted moves and successful moves are zero-initialized.")
116 {
117 CHECK_EQ(mover.get_attempted().total(), 0);
118 CHECK_EQ(mover.get_succeeded().total(), 0);
119 CHECK_EQ(mover.get_failed().total(), 0);
120 }
121 }
122 }
123}
124
125// This may take a while, so the scenario decorated with doctest::skip()
126// to disable by default
127SCENARIO("Using the MoveAlways algorithm" * doctest::test_suite("move_always") *
128 doctest::skip())
129{
130 spdlog::debug("Using the MoveAlways algorithm.\n");
131 GIVEN("A correctly-constructed Manifold_3.")
132 {
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.")
138 {
139 auto constexpr passes = 1;
140 auto constexpr checkpoint = 1;
141 MoveAlways_3 mover(passes, checkpoint);
142 THEN("A lot of moves are made.")
143 {
144 auto result = mover(manifold);
145 // Output
146 CHECK(result.is_valid());
147 AND_THEN(
148 "The correct number of attempted, successful, and failed moves are "
149 "made.")
150 {
151 CHECK_EQ(mover.get_attempted().total(),
152 mover.get_succeeded().total() + mover.get_failed().total());
153 // Human verification
154 mover.print_results();
155 }
156 }
157 }
158 }
159 GIVEN("A 4D manifold.")
160 {
161 WHEN("A MoveStrategy4 is constructed.")
162 {
163 auto constexpr passes = 1;
164 auto constexpr checkpoint = 1;
165 MoveAlways_4 const mover(passes, checkpoint);
166 THEN("The correct passes and checkpoints are instantiated.")
167 {
168 CHECK_EQ(mover.passes(), passes);
169 CHECK_EQ(mover.checkpoint(), checkpoint);
170 }
171 THEN("Attempted moves and successful moves are zero-initialized.")
172 {
173 CHECK_EQ(mover.get_attempted().two_four_moves(), 0);
174 CHECK_EQ(mover.get_failed().two_four_moves(), 0);
175 }
176 }
177 }
178}
Randomly selects moves to always perform on triangulations.
SCENARIO("Perform bistellar flip on Delaunay triangulation" *doctest::test_suite("bistellar"))
Select a move algorithm.