Browse Source

MeshTools: avoid global state in Tipsify test.

pull/85/head
Vladimír Vondruš 11 years ago
parent
commit
f81124e220
  1. 73
      src/Magnum/MeshTools/Test/TipsifyTest.cpp

73
src/Magnum/MeshTools/Test/TipsifyTest.cpp

@ -30,16 +30,11 @@
namespace Magnum { namespace MeshTools { namespace Test { namespace Magnum { namespace MeshTools { namespace Test {
class TipsifyTest: public TestSuite::Tester { struct TipsifyTest: TestSuite::Tester {
public: explicit TipsifyTest();
TipsifyTest();
void buildAdjacency(); void buildAdjacency();
void tipsify(); void tipsify();
private:
std::vector<UnsignedInt> indices;
std::size_t vertexCount;
}; };
/* /*
@ -57,37 +52,44 @@ class TipsifyTest: public TestSuite::Tester {
*/ */
TipsifyTest::TipsifyTest(): indices{ namespace {
4, 1, 0, const std::vector<UnsignedInt> Indices{
10, 9, 13, 4, 1, 0,
6, 3, 2, 10, 9, 13,
9, 5, 4, 6, 3, 2,
12, 9, 8, 9, 5, 4,
11, 7, 6, 12, 9, 8,
11, 7, 6,
14, 15, 11,
2, 1, 5, 14, 15, 11,
10, 6, 5, 2, 1, 5,
10, 5, 9, 10, 6, 5,
13, 14, 10, 10, 5, 9,
1, 4, 5, 13, 14, 10,
1, 4, 5,
7, 3, 6,
6, 2, 5, 7, 3, 6,
9, 4, 8, 6, 2, 5,
6, 10, 11, 9, 4, 8,
13, 9, 12, 6, 10, 11,
14, 11, 10, 13, 9, 12,
14, 11, 10,
16, 17, 18
}, vertexCount(19) { 16, 17, 18
};
constexpr std::size_t VertexCount = 19;
}
TipsifyTest::TipsifyTest() {
addTests({&TipsifyTest::buildAdjacency, addTests({&TipsifyTest::buildAdjacency,
&TipsifyTest::tipsify}); &TipsifyTest::tipsify});
} }
void TipsifyTest::buildAdjacency() { void TipsifyTest::buildAdjacency() {
std::vector<UnsignedInt> indices = Indices;
std::vector<UnsignedInt> liveTriangleCount, neighborOffset, neighbors; std::vector<UnsignedInt> liveTriangleCount, neighborOffset, neighbors;
Implementation::Tipsify(indices, vertexCount).buildAdjacency(liveTriangleCount, neighborOffset, neighbors); Implementation::Tipsify(indices, VertexCount).buildAdjacency(liveTriangleCount, neighborOffset, neighbors);
CORRADE_COMPARE(liveTriangleCount, (std::vector<UnsignedInt>{ CORRADE_COMPARE(liveTriangleCount, (std::vector<UnsignedInt>{
1, 3, 3, 2, 1, 3, 3, 2,
@ -131,7 +133,8 @@ void TipsifyTest::buildAdjacency() {
} }
void TipsifyTest::tipsify() { void TipsifyTest::tipsify() {
MeshTools::tipsify(indices, vertexCount, 3); std::vector<UnsignedInt> indices = Indices;
MeshTools::tipsify(indices, VertexCount, 3);
CORRADE_COMPARE(indices, (std::vector<UnsignedInt>{ CORRADE_COMPARE(indices, (std::vector<UnsignedInt>{
4, 1, 0, 4, 1, 0,

Loading…
Cancel
Save