Browse Source

GL: test Mesh::indexType() assertion as well.

Ugh the code coverage is abysmal here.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
5e23f09ffb
  1. 4
      src/Magnum/GL/Mesh.cpp
  2. 11
      src/Magnum/GL/Test/MeshGLTest.cpp

4
src/Magnum/GL/Mesh.cpp

@ -360,13 +360,13 @@ Mesh& Mesh::setLabel(const Containers::StringView label) {
#endif #endif
MeshIndexType Mesh::indexType() const { MeshIndexType Mesh::indexType() const {
CORRADE_ASSERT(_indexBuffer.id(), "Mesh::indexType(): mesh is not indexed", {}); CORRADE_ASSERT(_indexBuffer.id(), "GL::Mesh::indexType(): mesh is not indexed", {});
return _indexType; return _indexType;
} }
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
UnsignedInt Mesh::indexTypeSize() const { UnsignedInt Mesh::indexTypeSize() const {
CORRADE_ASSERT(_indexBuffer.id(), "Mesh::indexTypeSize(): mesh is not indexed", {}); CORRADE_ASSERT(_indexBuffer.id(), "GL::Mesh::indexTypeSize(): mesh is not indexed", {});
return meshIndexTypeSize(_indexType); return meshIndexTypeSize(_indexType);
} }

11
src/Magnum/GL/Test/MeshGLTest.cpp

@ -141,7 +141,7 @@ struct MeshGLTest: OpenGLTester {
template<class T> void setIndexBufferTransferOwnership(); template<class T> void setIndexBufferTransferOwnership();
template<class T> void setIndexBufferRangeTransferOwnership(); template<class T> void setIndexBufferRangeTransferOwnership();
void setIndexOffsetNotIndexed(); void indexTypeSetIndexOffsetNotIndexed();
void unbindVAOWhenSettingIndexBufferData(); void unbindVAOWhenSettingIndexBufferData();
void unbindIndexBufferWhenBindingVao(); void unbindIndexBufferWhenBindingVao();
@ -633,7 +633,7 @@ MeshGLTest::MeshGLTest() {
&MeshGLTest::setIndexBufferRangeTransferOwnership<GL::MeshIndexType>, &MeshGLTest::setIndexBufferRangeTransferOwnership<GL::MeshIndexType>,
&MeshGLTest::setIndexBufferRangeTransferOwnership<Magnum::MeshIndexType>, &MeshGLTest::setIndexBufferRangeTransferOwnership<Magnum::MeshIndexType>,
&MeshGLTest::setIndexOffsetNotIndexed, &MeshGLTest::indexTypeSetIndexOffsetNotIndexed,
&MeshGLTest::unbindVAOWhenSettingIndexBufferData, &MeshGLTest::unbindVAOWhenSettingIndexBufferData,
&MeshGLTest::unbindIndexBufferWhenBindingVao, &MeshGLTest::unbindIndexBufferWhenBindingVao,
@ -2677,7 +2677,7 @@ template<class T> void MeshGLTest::setIndexBufferRangeTransferOwnership() {
CORRADE_VERIFY(!glIsBuffer(id)); CORRADE_VERIFY(!glIsBuffer(id));
} }
void MeshGLTest::setIndexOffsetNotIndexed() { void MeshGLTest::indexTypeSetIndexOffsetNotIndexed() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_ASSERT();
Mesh mesh; Mesh mesh;
@ -2685,8 +2685,11 @@ void MeshGLTest::setIndexOffsetNotIndexed() {
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
mesh.indexType();
view.setIndexOffset(3); view.setIndexOffset(3);
CORRADE_COMPARE(out.str(), "GL::MeshView::setIndexOffset(): mesh is not indexed\n"); CORRADE_COMPARE(out.str(),
"GL::Mesh::indexType(): mesh is not indexed\n"
"GL::MeshView::setIndexOffset(): mesh is not indexed\n");
} }
void MeshGLTest::unbindVAOWhenSettingIndexBufferData() { void MeshGLTest::unbindVAOWhenSettingIndexBufferData() {

Loading…
Cancel
Save