Browse Source

Be nice and provide a clear assert in meshIndexTypeSize().

pull/388/head
Vladimír Vondruš 7 years ago
parent
commit
5dc791a75c
  1. 2
      src/Magnum/CMakeLists.txt
  2. 2
      src/Magnum/Mesh.cpp
  3. 2
      src/Magnum/Test/CMakeLists.txt
  4. 11
      src/Magnum/Test/MeshTest.cpp

2
src/Magnum/CMakeLists.txt

@ -29,7 +29,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
# Files shared between main library and unit test library # Files shared between main library and unit test library
set(Magnum_SRCS set(Magnum_SRCS
FileCallback.cpp FileCallback.cpp
Mesh.cpp
PixelStorage.cpp PixelStorage.cpp
Resource.cpp Resource.cpp
Sampler.cpp Sampler.cpp
@ -38,6 +37,7 @@ set(Magnum_SRCS
set(Magnum_GracefulAssert_SRCS set(Magnum_GracefulAssert_SRCS
Image.cpp Image.cpp
ImageView.cpp ImageView.cpp
Mesh.cpp
PixelFormat.cpp PixelFormat.cpp
Animation/Player.cpp Animation/Player.cpp

2
src/Magnum/Mesh.cpp

@ -39,7 +39,7 @@ UnsignedInt meshIndexTypeSize(MeshIndexType type) {
case MeshIndexType::UnsignedInt: return 4; case MeshIndexType::UnsignedInt: return 4;
} }
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ CORRADE_ASSERT(false, "meshIndexTypeSize(): invalid type" << type, {});
} }
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT

2
src/Magnum/Test/CMakeLists.txt

@ -27,7 +27,7 @@ corrade_add_test(ArrayTest ArrayTest.cpp LIBRARIES Magnum)
corrade_add_test(FileCallbackTest FileCallbackTest.cpp LIBRARIES Magnum) corrade_add_test(FileCallbackTest FileCallbackTest.cpp LIBRARIES Magnum)
corrade_add_test(ImageTest ImageTest.cpp LIBRARIES MagnumTestLib) corrade_add_test(ImageTest ImageTest.cpp LIBRARIES MagnumTestLib)
corrade_add_test(ImageViewTest ImageViewTest.cpp LIBRARIES MagnumTestLib) corrade_add_test(ImageViewTest ImageViewTest.cpp LIBRARIES MagnumTestLib)
corrade_add_test(MeshTest MeshTest.cpp LIBRARIES Magnum) corrade_add_test(MeshTest MeshTest.cpp LIBRARIES MagnumTestLib)
corrade_add_test(PixelFormatTest PixelFormatTest.cpp LIBRARIES MagnumTestLib) corrade_add_test(PixelFormatTest PixelFormatTest.cpp LIBRARIES MagnumTestLib)
target_compile_definitions(PixelFormatTest PRIVATE "CORRADE_GRACEFUL_ASSERT") target_compile_definitions(PixelFormatTest PRIVATE "CORRADE_GRACEFUL_ASSERT")
corrade_add_test(PixelStorageTest PixelStorageTest.cpp LIBRARIES Magnum) corrade_add_test(PixelStorageTest PixelStorageTest.cpp LIBRARIES Magnum)

11
src/Magnum/Test/MeshTest.cpp

@ -39,6 +39,7 @@ struct MeshTest: TestSuite::Tester {
void indexTypeMapping(); void indexTypeMapping();
void indexTypeSize(); void indexTypeSize();
void indexTypeSizeInvalid();
void debugPrimitive(); void debugPrimitive();
void debugIndexType(); void debugIndexType();
@ -51,6 +52,7 @@ MeshTest::MeshTest() {
&MeshTest::indexTypeMapping, &MeshTest::indexTypeMapping,
&MeshTest::indexTypeSize, &MeshTest::indexTypeSize,
&MeshTest::indexTypeSizeInvalid,
&MeshTest::debugPrimitive, &MeshTest::debugPrimitive,
&MeshTest::debugIndexType, &MeshTest::debugIndexType,
@ -138,6 +140,15 @@ void MeshTest::indexTypeSize() {
CORRADE_COMPARE(meshIndexTypeSize(MeshIndexType::UnsignedInt), 4); CORRADE_COMPARE(meshIndexTypeSize(MeshIndexType::UnsignedInt), 4);
} }
void MeshTest::indexTypeSizeInvalid() {
std::ostringstream out;
Error redirectError{&out};
meshIndexTypeSize(MeshIndexType(0xdead));
CORRADE_COMPARE(out.str(), "meshIndexTypeSize(): invalid type MeshIndexType(0xdead)\n");
}
void MeshTest::debugPrimitive() { void MeshTest::debugPrimitive() {
std::ostringstream o; std::ostringstream o;
Debug(&o) << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead); Debug(&o) << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead);

Loading…
Cancel
Save