Browse Source

Test: resolve some TODOs now that we have CORRADE_FAIL_IF().

Nice and tidy <3
pull/525/head
Vladimír Vondruš 4 years ago
parent
commit
d1d2007b92
  1. 28
      src/Magnum/Audio/Test/ContextTest.cpp
  2. 48
      src/Magnum/GL/Test/ContextTest.cpp
  3. 68
      src/Magnum/Vk/Test/ExtensionsTest.cpp

28
src/Magnum/Audio/Test/ContextTest.cpp

@ -78,33 +78,21 @@ void ContextTest::extensions() {
for(const Extension& e: Extension::extensions()) {
CORRADE_ITERATION(e.string());
/** @todo convert to CORRADE_ERROR() when that's done */
CORRADE_FAIL_IF(!previous.empty() && previous >= e.string(),
"Extension not sorted after" << previous);
if(!previous.empty() && previous >= e.string()) {
Error{} << "Extension not sorted after" << previous;
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.index() >= Implementation::ExtensionCount,
"Index" << e.index() << "larger than" << Implementation::ExtensionCount);
if(e.index() >= Implementation::ExtensionCount) {
Error{} << "Index" << e.index() << "larger than" << Implementation::ExtensionCount;
CORRADE_VERIFY(false);
}
if(used[e.index()]) {
Error{} << "Index" << e.index() << "already used by" << used[e.index()];
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(used[e.index()],
"Index" << e.index() << "already used by" << used[e.index()]);
used[e.index()] = e.string();
if(!unique.insert(e.string()).second) {
Error{} << "Extension listed more than once";
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(!unique.insert(e.string()).second,
"Extension listed more than once");
previous = e.string();
}
CORRADE_VERIFY(true);
}
void ContextTest::debugHrtfStatus() {

48
src/Magnum/GL/Test/ContextTest.cpp

@ -400,61 +400,43 @@ void ContextTest::extensions() {
CORRADE_ITERATION(version);
CORRADE_ITERATION(e.string());
/** @todo convert to CORRADE_ERROR() when that's done */
CORRADE_FAIL_IF(!previous.empty() && previous >= e.string(),
"Extension not sorted after" << previous);
if(!previous.empty() && previous >= e.string()) {
Error{} << "Extension not sorted after" << previous;
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.index() >= GL::Implementation::ExtensionCount,
"Index" << e.index() << "larger than" << GL::Implementation::ExtensionCount);
if(e.index() >= GL::Implementation::ExtensionCount) {
Error{} << "Index" << e.index() << "larger than" << GL::Implementation::ExtensionCount;
CORRADE_VERIFY(false);
}
if(used[e.index()]) {
Error{} << "Index" << e.index() << "already used by" << used[e.index()];
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(used[e.index()],
"Index" << e.index() << "already used by" << used[e.index()]);
used[e.index()] = e.string();
if(!unique.insert(e.string()).second) {
Error{} << "Extension listed more than once";
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(!unique.insert(e.string()).second,
"Extension listed more than once");
CORRADE_VERIFY(Int(e.coreVersion()) >= Int(e.requiredVersion()));
if(e.coreVersion() != version
bool coreVersionMismatch = e.coreVersion() != version
#if defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)
/* These two are replaced by EXT_color_buffer_float for 2.0,
but aren't core in WebGL 2 */
&& e.index() != Extensions::EXT::color_buffer_half_float::Index
&& e.index() != Extensions::WEBGL::color_buffer_float::Index
#endif
) {
Error{} << "Extension should have core version" << version << "but has" << e.coreVersion();
CORRADE_VERIFY(false);
}
;
CORRADE_FAIL_IF(coreVersionMismatch, "Extension should have core version" << version << "but has" << e.coreVersion());
#ifdef MAGNUM_TARGET_GLES2
if(e.requiredVersion() != Version::GLES200) {
Error{} << "Extension should have required version" << Version::GLES200 << "but has" << e.requiredVersion();
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.requiredVersion() != Version::GLES200,
"Extension should have required version" << Version::GLES200 << "but has" << e.requiredVersion());
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2)
if(e.coreVersion() == Version::GLES300 && e.index() != Extensions::MAGNUM::shader_vertex_id::Index) {
Error{} << "Extension has core version" << e.coreVersion() << "on a GLES3 build -- it shouldn't be present at all";
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.coreVersion() == Version::GLES300 && e.index() != Extensions::MAGNUM::shader_vertex_id::Index,
"Extension has core version" << e.coreVersion() << "on a GLES3 build -- it shouldn't be present at all");
#endif
previous = e.string();
}
}
CORRADE_VERIFY(true);
}
void ContextTest::debugFlag() {

68
src/Magnum/Vk/Test/ExtensionsTest.cpp

@ -174,42 +174,28 @@ void ExtensionsTest::instanceExtensions() {
for(const InstanceExtension& e: InstanceExtension::extensions(version)) {
CORRADE_ITERATION(e.string());
/** @todo convert to CORRADE_ERROR() when that's done */
/* Binary search is performed on each list to find known
extensions, so the exts have to be sorted */
if(!previous.isEmpty() && previous >= e.string()) {
Error{} << "Extension not sorted after" << previous;
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(!previous.isEmpty() && previous >= e.string(),
"Extension not sorted after" << previous);
if(e.index() >= Implementation::InstanceExtensionCount) {
Error{} << "Index" << e.index() << "larger than" << Implementation::InstanceExtensionCount;
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.index() >= Implementation::InstanceExtensionCount,
"Index" << e.index() << "larger than" << Implementation::InstanceExtensionCount);
if(used[e.index()] != nullptr) {
Error{} << "Index" << e.index() << "already used by" << used[e.index()];
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(used[e.index()] != nullptr,
"Index" << e.index() << "already used by" << used[e.index()]);
used[e.index()] = e.string();
if(!unique.insert(e.string()).second) {
Error{} << "Extension listed more than once";
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(!unique.insert(e.string()).second,
"Extension listed more than once");
CORRADE_COMPARE_AS(e.coreVersion(), e.requiredVersion(), TestSuite::Compare::GreaterOrEqual);
if(e.coreVersion() != version) {
Error{} << "Extension should have core version" << version << "but has" << e.coreVersion();
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.coreVersion() != version,
"Extension should have core version" << version << "but has" << e.coreVersion());
previous = e.string();
}
}
CORRADE_VERIFY(true);
}
void ExtensionsTest::extensions() {
@ -230,42 +216,28 @@ void ExtensionsTest::extensions() {
for(const Extension& e: Extension::extensions(version)) {
CORRADE_ITERATION(e.string());
/** @todo convert to CORRADE_ERROR() when that's done */
/* Binary search is performed on each list to find known
extensions, so the exts have to be sorted */
if(!previous.isEmpty() && previous >= e.string()) {
Error{} << "Extension not sorted after" << previous;
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(!previous.isEmpty() && previous >= e.string(),
"Extension not sorted after" << previous);
if(e.index() >= Implementation::ExtensionCount) {
Error{} << "Index" << e.index() << "larger than" << Implementation::ExtensionCount;
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.index() >= Implementation::ExtensionCount,
"Index" << e.index() << "larger than" << Implementation::ExtensionCount);
if(used[e.index()] != nullptr) {
Error{} << "Index" << e.index() << "already used by" << used[e.index()];
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(used[e.index()] != nullptr,
"Index" << e.index() << "already used by" << used[e.index()]);
used[e.index()] = e.string();
if(!unique.insert(e.string()).second) {
Error{} << "Extension listed more than once";
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(!unique.insert(e.string()).second,
"Extension listed more than once");
CORRADE_COMPARE_AS(e.coreVersion(), e.requiredVersion(), TestSuite::Compare::GreaterOrEqual);
if(e.coreVersion() != version) {
Error{} << "Extensio should have core version" << version << "but has" << e.coreVersion();
CORRADE_VERIFY(false);
}
CORRADE_FAIL_IF(e.coreVersion() != version,
"Extension should have core version" << version << "but has" << e.coreVersion());
previous = e.string();
}
}
CORRADE_VERIFY(true);
}
}}}}

Loading…
Cancel
Save