Browse Source

Test: fix false sense of security in pixel/mesh enum mapping tests.

The stripped-down versions didn't actually test for correct order
because there was no external API result to check against expected
output. That's fixed now, plus clarified some comments and removed
copypasted nonsense.
mousecapture
Vladimír Vondruš 6 years ago
parent
commit
50ac6d1a13
  1. 8
      src/Magnum/GL/Test/PixelFormatTest.cpp
  2. 10
      src/Magnum/Test/MeshTest.cpp
  3. 18
      src/Magnum/Test/PixelFormatTest.cpp
  4. 8
      src/Magnum/Vk/Test/EnumsTest.cpp

8
src/Magnum/GL/Test/PixelFormatTest.cpp

@ -117,8 +117,8 @@ void PixelFormatTest::mapFormatTypeTextureFormat() {
for(UnsignedInt i = 1; i <= 0xffff; ++i) { for(UnsignedInt i = 1; i <= 0xffff; ++i) {
const auto format = Magnum::PixelFormat(i); const auto format = Magnum::PixelFormat(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) - that there was no gap (unhandled value inside the range)
- that a particular pixel format maps to a particular GL format - that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */ - that a particular pixel type maps to a particular GL type */
@ -327,8 +327,8 @@ void PixelFormatTest::mapCompressedFormatTextureFormat() {
for(UnsignedInt i = 1; i <= 0xffff; ++i) { for(UnsignedInt i = 1; i <= 0xffff; ++i) {
const auto format = Magnum::CompressedPixelFormat(i); const auto format = Magnum::CompressedPixelFormat(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) - that there was no gap (unhandled value inside the range)
- that a particular pixel format maps to a particular GL format - that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */ - that a particular pixel type maps to a particular GL type */

10
src/Magnum/Test/MeshTest.cpp

@ -67,8 +67,8 @@ void MeshTest::primitiveMapping() {
for(UnsignedInt i = 0; i <= 0xff; ++i) { for(UnsignedInt i = 0; i <= 0xff; ++i) {
const auto primitive = MeshPrimitive(i); const auto primitive = MeshPrimitive(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) */ - that there was no gap (unhandled value inside the range) */
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -77,6 +77,7 @@ void MeshTest::primitiveMapping() {
switch(primitive) { switch(primitive) {
#define _c(primitive) \ #define _c(primitive) \
case MeshPrimitive::primitive: \ case MeshPrimitive::primitive: \
CORRADE_COMPARE(Utility::ConfigurationValue<MeshPrimitive>::toString(MeshPrimitive::primitive, {}), #primitive); \
CORRADE_COMPARE(nextHandled, i); \ CORRADE_COMPARE(nextHandled, i); \
CORRADE_COMPARE(firstUnhandled, 0xff); \ CORRADE_COMPARE(firstUnhandled, 0xff); \
++nextHandled; \ ++nextHandled; \
@ -104,8 +105,8 @@ void MeshTest::indexTypeMapping() {
for(UnsignedInt i = 0; i <= 0xff; ++i) { for(UnsignedInt i = 0; i <= 0xff; ++i) {
const auto type = MeshIndexType(i); const auto type = MeshIndexType(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) */ - that there was no gap (unhandled value inside the range) */
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -114,6 +115,7 @@ void MeshTest::indexTypeMapping() {
switch(type) { switch(type) {
#define _c(type) \ #define _c(type) \
case MeshIndexType::type: \ case MeshIndexType::type: \
CORRADE_COMPARE(Utility::ConfigurationValue<MeshIndexType>::toString(MeshIndexType::type, {}), #type); \
CORRADE_COMPARE(nextHandled, i); \ CORRADE_COMPARE(nextHandled, i); \
CORRADE_COMPARE(firstUnhandled, 0xff); \ CORRADE_COMPARE(firstUnhandled, 0xff); \
++nextHandled; \ ++nextHandled; \

18
src/Magnum/Test/PixelFormatTest.cpp

@ -112,11 +112,9 @@ void PixelFormatTest::mapping() {
for(UnsignedInt i = 1; i <= 0xffff; ++i) { for(UnsignedInt i = 1; i <= 0xffff; ++i) {
const auto format = PixelFormat(i); const auto format = PixelFormat(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) - that there was no gap (unhandled value inside the range) */
- that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
@ -124,6 +122,7 @@ void PixelFormatTest::mapping() {
switch(format) { switch(format) {
#define _c(format) \ #define _c(format) \
case PixelFormat::format: \ case PixelFormat::format: \
CORRADE_COMPARE(Utility::ConfigurationValue<PixelFormat>::toString(PixelFormat::format, {}), #format); \
CORRADE_COMPARE(nextHandled, i); \ CORRADE_COMPARE(nextHandled, i); \
CORRADE_COMPARE(firstUnhandled, 0xffff); \ CORRADE_COMPARE(firstUnhandled, 0xffff); \
++nextHandled; \ ++nextHandled; \
@ -152,11 +151,9 @@ void PixelFormatTest::compressedMapping() {
for(UnsignedInt i = 1; i <= 0xffff; ++i) { for(UnsignedInt i = 1; i <= 0xffff; ++i) {
const auto format = CompressedPixelFormat(i); const auto format = CompressedPixelFormat(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) - that there was no gap (unhandled value inside the range) */
- that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
@ -164,6 +161,7 @@ void PixelFormatTest::compressedMapping() {
switch(format) { switch(format) {
#define _c(format, width, height, depth, size) \ #define _c(format, width, height, depth, size) \
case CompressedPixelFormat::format: \ case CompressedPixelFormat::format: \
CORRADE_COMPARE(Utility::ConfigurationValue<CompressedPixelFormat>::toString(CompressedPixelFormat::format, {}), #format); \
CORRADE_COMPARE(nextHandled, i); \ CORRADE_COMPARE(nextHandled, i); \
CORRADE_COMPARE(firstUnhandled, 0xffff); \ CORRADE_COMPARE(firstUnhandled, 0xffff); \
CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::format), (Vector3i{width, height, depth})); \ CORRADE_COMPARE(Magnum::compressedBlockSize(CompressedPixelFormat::format), (Vector3i{width, height, depth})); \

8
src/Magnum/Vk/Test/EnumsTest.cpp

@ -185,8 +185,8 @@ void EnumsTest::mapVkFormat() {
for(UnsignedInt i = 1; i <= 0xffff; ++i) { for(UnsignedInt i = 1; i <= 0xffff; ++i) {
const auto format = Magnum::PixelFormat(i); const auto format = Magnum::PixelFormat(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) - that there was no gap (unhandled value inside the range)
- that a particular pixel format maps to a particular GL format - that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */ - that a particular pixel type maps to a particular GL type */
@ -273,8 +273,8 @@ void EnumsTest::mapVkFormatCompressed() {
for(UnsignedInt i = 1; i <= 0xffff; ++i) { for(UnsignedInt i = 1; i <= 0xffff; ++i) {
const auto format = Magnum::CompressedPixelFormat(i); const auto format = Magnum::CompressedPixelFormat(i);
/* Each case verifies: /* Each case verifies:
- that the cases are ordered by number (so insertion here is done in - that the entries are ordered by number by comparing a function to
proper place) expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range) - that there was no gap (unhandled value inside the range)
- that a particular pixel format maps to a particular GL format - that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */ - that a particular pixel type maps to a particular GL type */

Loading…
Cancel
Save