|
|
|
@ -37,14 +37,13 @@ struct MeshTest: TestSuite::Tester { |
|
|
|
explicit MeshTest(); |
|
|
|
explicit MeshTest(); |
|
|
|
|
|
|
|
|
|
|
|
void primitiveMapping(); |
|
|
|
void primitiveMapping(); |
|
|
|
void indexTypeMapping(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void primitiveIsImplementationSpecific(); |
|
|
|
void primitiveIsImplementationSpecific(); |
|
|
|
void primitiveWrap(); |
|
|
|
void primitiveWrap(); |
|
|
|
void primitiveWrapInvalid(); |
|
|
|
void primitiveWrapInvalid(); |
|
|
|
void primitiveUnwrap(); |
|
|
|
void primitiveUnwrap(); |
|
|
|
void primitiveUnwrapInvalid(); |
|
|
|
void primitiveUnwrapInvalid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void indexTypeMapping(); |
|
|
|
void indexTypeSize(); |
|
|
|
void indexTypeSize(); |
|
|
|
void indexTypeSizeInvalid(); |
|
|
|
void indexTypeSizeInvalid(); |
|
|
|
|
|
|
|
|
|
|
|
@ -58,14 +57,13 @@ struct MeshTest: TestSuite::Tester { |
|
|
|
|
|
|
|
|
|
|
|
MeshTest::MeshTest() { |
|
|
|
MeshTest::MeshTest() { |
|
|
|
addTests({&MeshTest::primitiveMapping, |
|
|
|
addTests({&MeshTest::primitiveMapping, |
|
|
|
&MeshTest::indexTypeMapping, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&MeshTest::primitiveIsImplementationSpecific, |
|
|
|
&MeshTest::primitiveIsImplementationSpecific, |
|
|
|
&MeshTest::primitiveWrap, |
|
|
|
&MeshTest::primitiveWrap, |
|
|
|
&MeshTest::primitiveWrapInvalid, |
|
|
|
&MeshTest::primitiveWrapInvalid, |
|
|
|
&MeshTest::primitiveUnwrap, |
|
|
|
&MeshTest::primitiveUnwrap, |
|
|
|
&MeshTest::primitiveUnwrapInvalid, |
|
|
|
&MeshTest::primitiveUnwrapInvalid, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&MeshTest::indexTypeMapping, |
|
|
|
&MeshTest::indexTypeSize, |
|
|
|
&MeshTest::indexTypeSize, |
|
|
|
&MeshTest::indexTypeSizeInvalid, |
|
|
|
&MeshTest::indexTypeSizeInvalid, |
|
|
|
|
|
|
|
|
|
|
|
@ -115,44 +113,6 @@ void MeshTest::primitiveMapping() { |
|
|
|
CORRADE_COMPARE(firstUnhandled, 0xff); |
|
|
|
CORRADE_COMPARE(firstUnhandled, 0xff); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MeshTest::indexTypeMapping() { |
|
|
|
|
|
|
|
/* This goes through the first 8 bits, which should be enough. */ |
|
|
|
|
|
|
|
UnsignedInt firstUnhandled = 0xff; |
|
|
|
|
|
|
|
UnsignedInt nextHandled = 1; /* 0 is an invalid type */ |
|
|
|
|
|
|
|
for(UnsignedInt i = 1; i <= 0xff; ++i) { |
|
|
|
|
|
|
|
const auto type = MeshIndexType(i); |
|
|
|
|
|
|
|
/* Each case verifies:
|
|
|
|
|
|
|
|
- that the entries are ordered by number by comparing a function to |
|
|
|
|
|
|
|
expected result (so insertion here is done in proper place) |
|
|
|
|
|
|
|
- that there was no gap (unhandled value inside the range) */ |
|
|
|
|
|
|
|
#ifdef __GNUC__ |
|
|
|
|
|
|
|
#pragma GCC diagnostic push |
|
|
|
|
|
|
|
#pragma GCC diagnostic error "-Wswitch" |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
switch(type) { |
|
|
|
|
|
|
|
#define _c(type) \ |
|
|
|
|
|
|
|
case MeshIndexType::type: \
|
|
|
|
|
|
|
|
CORRADE_COMPARE(Utility::ConfigurationValue<MeshIndexType>::toString(MeshIndexType::type, {}), #type); \
|
|
|
|
|
|
|
|
CORRADE_COMPARE(nextHandled, i); \
|
|
|
|
|
|
|
|
CORRADE_COMPARE(firstUnhandled, 0xff); \
|
|
|
|
|
|
|
|
++nextHandled; \
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
#include "Magnum/Implementation/meshIndexTypeMapping.hpp" |
|
|
|
|
|
|
|
#undef _c |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef __GNUC__ |
|
|
|
|
|
|
|
#pragma GCC diagnostic pop |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Not handled by any value, remember -- we might either be at the end
|
|
|
|
|
|
|
|
of the enum range (which is okay) or some value might be unhandled |
|
|
|
|
|
|
|
here */ |
|
|
|
|
|
|
|
firstUnhandled = i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(firstUnhandled, 0xff); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MeshTest::primitiveIsImplementationSpecific() { |
|
|
|
void MeshTest::primitiveIsImplementationSpecific() { |
|
|
|
constexpr bool a = isMeshPrimitiveImplementationSpecific(MeshPrimitive::Lines); |
|
|
|
constexpr bool a = isMeshPrimitiveImplementationSpecific(MeshPrimitive::Lines); |
|
|
|
constexpr bool b = isMeshPrimitiveImplementationSpecific(MeshPrimitive(0x8000dead)); |
|
|
|
constexpr bool b = isMeshPrimitiveImplementationSpecific(MeshPrimitive(0x8000dead)); |
|
|
|
@ -196,6 +156,44 @@ void MeshTest::primitiveUnwrapInvalid() { |
|
|
|
CORRADE_COMPARE(out.str(), "meshPrimitiveUnwrap(): MeshPrimitive::Triangles isn't a wrapped implementation-specific value\n"); |
|
|
|
CORRADE_COMPARE(out.str(), "meshPrimitiveUnwrap(): MeshPrimitive::Triangles isn't a wrapped implementation-specific value\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MeshTest::indexTypeMapping() { |
|
|
|
|
|
|
|
/* This goes through the first 8 bits, which should be enough. */ |
|
|
|
|
|
|
|
UnsignedInt firstUnhandled = 0xff; |
|
|
|
|
|
|
|
UnsignedInt nextHandled = 1; /* 0 is an invalid type */ |
|
|
|
|
|
|
|
for(UnsignedInt i = 1; i <= 0xff; ++i) { |
|
|
|
|
|
|
|
const auto type = MeshIndexType(i); |
|
|
|
|
|
|
|
/* Each case verifies:
|
|
|
|
|
|
|
|
- that the entries are ordered by number by comparing a function to |
|
|
|
|
|
|
|
expected result (so insertion here is done in proper place) |
|
|
|
|
|
|
|
- that there was no gap (unhandled value inside the range) */ |
|
|
|
|
|
|
|
#ifdef __GNUC__ |
|
|
|
|
|
|
|
#pragma GCC diagnostic push |
|
|
|
|
|
|
|
#pragma GCC diagnostic error "-Wswitch" |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
switch(type) { |
|
|
|
|
|
|
|
#define _c(type) \ |
|
|
|
|
|
|
|
case MeshIndexType::type: \
|
|
|
|
|
|
|
|
CORRADE_COMPARE(Utility::ConfigurationValue<MeshIndexType>::toString(MeshIndexType::type, {}), #type); \
|
|
|
|
|
|
|
|
CORRADE_COMPARE(nextHandled, i); \
|
|
|
|
|
|
|
|
CORRADE_COMPARE(firstUnhandled, 0xff); \
|
|
|
|
|
|
|
|
++nextHandled; \
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
#include "Magnum/Implementation/meshIndexTypeMapping.hpp" |
|
|
|
|
|
|
|
#undef _c |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef __GNUC__ |
|
|
|
|
|
|
|
#pragma GCC diagnostic pop |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Not handled by any value, remember -- we might either be at the end
|
|
|
|
|
|
|
|
of the enum range (which is okay) or some value might be unhandled |
|
|
|
|
|
|
|
here */ |
|
|
|
|
|
|
|
firstUnhandled = i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(firstUnhandled, 0xff); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MeshTest::indexTypeSize() { |
|
|
|
void MeshTest::indexTypeSize() { |
|
|
|
CORRADE_COMPARE(meshIndexTypeSize(MeshIndexType::UnsignedByte), 1); |
|
|
|
CORRADE_COMPARE(meshIndexTypeSize(MeshIndexType::UnsignedByte), 1); |
|
|
|
CORRADE_COMPARE(meshIndexTypeSize(MeshIndexType::UnsignedShort), 2); |
|
|
|
CORRADE_COMPARE(meshIndexTypeSize(MeshIndexType::UnsignedShort), 2); |
|
|
|
|