-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathApply_move_test.cpp
188 lines (181 loc) · 6.3 KB
/
Apply_move_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*******************************************************************************
Causal Dynamical Triangulations in C++ using CGAL
Copyright © 2019 Adam Getchell
******************************************************************************/
/// @file Apply_move_test.cpp
/// @brief Applying ergodic moves to manifolds
/// @author Adam Getchell
/// @details Tests applying ergodic moves singly and in groups
#include "Apply_move.hpp"
#include <doctest/doctest.h>
#include "Ergodic_moves_3.hpp"
using namespace std;
SCENARIO("Apply an ergodic move to 2+1 manifolds" *
doctest::test_suite("apply"))
{
GIVEN("A 2+1 dimensional spherical manifold.")
{
auto constexpr desired_simplices = 9600;
auto constexpr desired_timeslices = 7;
manifolds::Manifold_3 manifold(desired_simplices, desired_timeslices);
REQUIRE(manifold.is_correct());
// Copy of manifold
auto manifold_before = manifold;
WHEN("A null move is applied to the manifold.")
{
spdlog::debug("Applying null move to manifold.\n");
if (auto result = apply_move(manifold, ergodic_moves::null_move); result)
{
manifold = result.value();
// Update Geometry and Foliated_triangulation with new info
manifold.update();
}
else
{
spdlog::debug("{}", result.error());
REQUIRE(result.has_value());
}
THEN("The resulting manifold is valid and unchanged.")
{
CHECK(manifold.is_valid());
CHECK_EQ(manifold_before.simplices(), manifold.simplices());
CHECK_EQ(manifold_before.faces(), manifold.faces());
CHECK_EQ(manifold_before.edges(), manifold.edges());
CHECK_EQ(manifold_before.vertices(), manifold.vertices());
// Human verification
fmt::print("Old manifold.\n");
manifold_before.print_details();
fmt::print("New manifold after null move:\n");
manifold.print_details();
}
}
WHEN("A (2,3) move is applied to the manifold.")
{
spdlog::debug("Applying (2,3) move to manifold.\n");
if (auto result = apply_move(manifold, ergodic_moves::do_23_move); result)
{
manifold = result.value();
// Update Geometry and Foliated_triangulation with new info
manifold.update();
}
else
{
spdlog::debug("{}", result.error());
REQUIRE(result.has_value());
}
THEN("The resulting manifold has the applied move.")
{
CHECK(ergodic_moves::check_move(manifold_before, manifold,
move_tracker::move_type::TWO_THREE));
// Human verification
fmt::print("Old manifold.\n");
manifold_before.print_details();
fmt::print("New manifold after (2,3) move:\n");
manifold.print_details();
}
}
WHEN("A (3,2) move is applied to the manifold.")
{
spdlog::debug("Applying (3,2) move to manifold.\n");
if (auto result = apply_move(manifold, ergodic_moves::do_32_move); result)
{
manifold = result.value();
// Update Geometry and Foliated_triangulation with new info
manifold.update();
}
else
{
spdlog::debug("{}", result.error());
// Stop further tests
REQUIRE(result.has_value());
}
THEN("The resulting manifold has the applied move.")
{
CHECK(ergodic_moves::check_move(manifold_before, manifold,
move_tracker::move_type::THREE_TWO));
// Human verification
fmt::print("Old manifold.\n");
manifold_before.print_details();
fmt::print("New manifold after (3,2) move:\n");
manifold.print_details();
}
}
WHEN("A (2,6) move is applied to the manifold.")
{
spdlog::debug("Applying (2,6) move to manifold.\n");
if (auto result = apply_move(manifold, ergodic_moves::do_26_move); result)
{
manifold = result.value();
// Update Geometry and Foliated_triangulation with new info
manifold.update();
}
else
{
spdlog::debug("{}", result.error());
// Stop further tests
REQUIRE(result.has_value());
}
THEN("The resulting manifold has the applied move.")
{
CHECK(ergodic_moves::check_move(manifold_before, manifold,
move_tracker::move_type::TWO_SIX));
// Human verification
fmt::print("Old manifold.\n");
manifold_before.print_details();
fmt::print("New manifold after (2,6) move:\n");
manifold.print_details();
}
}
WHEN("A (6,2) move is applied to the manifold.")
{
spdlog::debug("Applying (6,2) move to manifold.\n");
if (auto result = apply_move(manifold, ergodic_moves::do_62_move); result)
{
manifold = result.value();
// Update Geometry and Foliated_triangulation with new info
manifold.update();
}
else
{
spdlog::debug("{}", result.error());
CHECK(result.has_value());
}
THEN("The resulting manifold has the applied move.")
{
CHECK(ergodic_moves::check_move(manifold_before, manifold,
move_tracker::move_type::SIX_TWO));
// Human verification
fmt::print("Old manifold.\n");
manifold_before.print_details();
fmt::print("New manifold after (6,2) move:\n");
manifold.print_details();
}
}
WHEN("A (4,4) move is applied to the manifold.")
{
spdlog::debug("Applying (4,4) move to manifold.\n");
if (auto result = apply_move(manifold, ergodic_moves::do_44_move); result)
{
manifold = result.value();
// Update Geometry and Foliated_triangulation with new info
manifold.update();
}
else
{
spdlog::debug("{}", result.error());
// Stop further tests
REQUIRE(result.has_value());
}
THEN("The resulting manifold has the applied move.")
{
CHECK(ergodic_moves::check_move(manifold_before, manifold,
move_tracker::move_type::FOUR_FOUR));
// Human verification
fmt::print("Old manifold.\n");
manifold_before.print_details();
fmt::print("New manifold after (4,4) move:\n");
manifold.print_details();
}
}
}
}