2
/**************************************************************************
4
* Regina - A Normal Surface Theory Calculator *
7
* Copyright (c) 1999-2014, Ben Burton *
8
* For further details contact Ben Burton (bab@debian.org). *
10
* This program is free software; you can redistribute it and/or *
11
* modify it under the terms of the GNU General Public License as *
12
* published by the Free Software Foundation; either version 2 of the *
13
* License, or (at your option) any later version. *
15
* As an exception, when this program is distributed through (i) the *
16
* App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or *
17
* (iii) Google Play by Google Inc., then that store may impose any *
18
* digital rights management, device limits and/or redistribution *
19
* restrictions that are required by its terms of service. *
21
* This program is distributed in the hope that it will be useful, but *
22
* WITHOUT ANY WARRANTY; without even the implied warranty of *
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
24
* General Public License for more details. *
26
* You should have received a copy of the GNU General Public *
27
* License along with this program; if not, write to the Free *
28
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
29
* MA 02110-1301, USA. *
31
**************************************************************************/
35
#include <cppunit/extensions/HelperMacros.h>
36
#include "dim2/dim2exampletriangulation.h"
37
#include "dim2/dim2triangulation.h"
39
#include "testsuite/exhaustive.h"
40
#include "testsuite/generic/generictriangulation.h"
41
#include "testsuite/dim2/testdim2.h"
43
using regina::Dim2Triangulation;
44
using regina::Dim2ExampleTriangulation;
46
class Dim2TriangulationTest : public TriangulationTest<2> {
47
CPPUNIT_TEST_SUITE(Dim2TriangulationTest);
50
CPPUNIT_TEST(makeCanonical);
51
CPPUNIT_TEST(isomorphismSignature);
53
// Dimension-specific tests:
54
CPPUNIT_TEST(eltMove13);
56
CPPUNIT_TEST_SUITE_END();
60
Dim2Triangulation empty;
61
/**< An empty triangulation. */
65
/**< A 2-sphere with two triangles. */
66
Dim2Triangulation s2Tet;
67
/**< A 2-sphere with four triangles. */
68
Dim2Triangulation s2Oct;
69
/**< A 2-sphere with eight triangles. */
70
Dim2Triangulation torus;
71
/**< A torus with two triangles. */
72
Dim2Triangulation torus2;
73
/**< A genus two torus. */
75
// Closed non-orientable:
76
Dim2Triangulation rp2;
77
/**< A projective plane with two triangles. */
79
/**< A Klein bottle with two triangles. */
82
Dim2Triangulation disc;
83
/**< A disc with one triangle. */
84
Dim2Triangulation annulus;
85
/**< An annulus with two triangles. */
86
Dim2Triangulation mobius;
87
/**< A Mobius band with one triangle. */
89
// Disconnected triangulations:
90
Dim2Triangulation disjoint2;
91
/**< A disjoint union of two triangulations. */
92
Dim2Triangulation disjoint3;
93
/**< A disjoint union of three triangulations. */
96
void copyAndDelete(Dim2Triangulation& dest, Dim2Triangulation* source) {
97
dest.insertTriangulation(*source);
98
dest.setPacketLabel(source->getPacketLabel());
103
empty.setPacketLabel("Empty triangulation");
105
copyAndDelete(s2, Dim2ExampleTriangulation::sphere());
106
s2.setPacketLabel("S^2");
108
copyAndDelete(s2Tet, Dim2ExampleTriangulation::sphereTetrahedron());
109
s2Tet.setPacketLabel("Tetrahedron boundary");
111
copyAndDelete(s2Oct, Dim2ExampleTriangulation::sphereOctahedron());
112
s2Oct.setPacketLabel("Octahedron boundary");
114
copyAndDelete(torus, Dim2ExampleTriangulation::torus());
115
torus.setPacketLabel("Torus");
117
copyAndDelete(torus2, Dim2ExampleTriangulation::orientable(2, 0));
118
torus2.setPacketLabel("Genus 2 torus");
120
copyAndDelete(rp2, Dim2ExampleTriangulation::rp2());
121
rp2.setPacketLabel("RP^2");
123
copyAndDelete(kb, Dim2ExampleTriangulation::kb());
124
kb.setPacketLabel("KB");
126
copyAndDelete(disc, Dim2ExampleTriangulation::disc());
127
disc.setPacketLabel("Disc");
129
copyAndDelete(annulus, Dim2ExampleTriangulation::annulus());
130
annulus.setPacketLabel("Annulus");
132
copyAndDelete(mobius, Dim2ExampleTriangulation::mobius());
133
mobius.setPacketLabel("Mobius band");
135
disjoint2.insertTriangulation(torus);
136
disjoint2.insertTriangulation(mobius);
137
disjoint2.setPacketLabel("Torus U Mobius");
139
disjoint3.insertTriangulation(kb);
140
disjoint3.insertTriangulation(annulus);
141
disjoint3.insertTriangulation(s2);
142
disjoint3.setPacketLabel("KB U Annulus U S^2");
149
* Run a given test over all hand-coded cases.
151
void testManualAll(Dim2TriangulationTestFunction f) {
167
void makeCanonical() {
168
testManualAll(verifyMakeCanonical);
171
void isomorphismSignature() {
172
testManualAll(verifyIsomorphismSignature);
175
static void verifyEltMove13(Dim2Triangulation* tri) {
176
unsigned long n = tri->getNumberOfTriangles();
177
for (unsigned long i = 0; i < n; ++i) {
178
Dim2Triangulation large(*tri);
179
large.oneThreeMove(large.getTriangle(i));
181
if (large.getNumberOfTriangles() != n + 2) {
182
std::ostringstream msg;
183
msg << tri->getPacketLabel() << ", tri " << i << ": "
184
<< "1-3 move gives wrong # triangles.";
185
CPPUNIT_FAIL(msg.str());
188
if (large.isOrientable() != tri->isOrientable()) {
189
std::ostringstream msg;
190
msg << tri->getPacketLabel() << ", tri " << i << ": "
191
<< "1-3 move changes orientability.";
192
CPPUNIT_FAIL(msg.str());
195
if (large.isClosed() != tri->isClosed()) {
196
std::ostringstream msg;
197
msg << tri->getPacketLabel() << ", tri " << i << ": "
198
<< "1-3 move changes closedness.";
199
CPPUNIT_FAIL(msg.str());
202
if (large.getNumberOfBoundaryComponents() !=
203
tri->getNumberOfBoundaryComponents()) {
204
std::ostringstream msg;
205
msg << tri->getPacketLabel() << ", tri " << i << ": "
206
<< "1-3 move changes # boundary components.";
207
CPPUNIT_FAIL(msg.str());
210
if (large.getEulerChar() != tri->getEulerChar()) {
211
std::ostringstream msg;
212
msg << tri->getPacketLabel() << ", tri " << i << ": "
213
<< "1-3 move changes Euler characteristic.";
214
CPPUNIT_FAIL(msg.str());
220
testManualAll(verifyEltMove13);
224
void addDim2Triangulation(CppUnit::TextUi::TestRunner& runner) {
225
runner.addTest(Dim2TriangulationTest::suite());