From 4be74e225bc6abae9e494561e855ca080b0c3256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 5 Dec 2021 18:41:36 +0100 Subject: [PATCH] Test: wait, Mac, what the heck are you doing. So I get a crash by printing a null char* pointer? Amazing! --- src/Magnum/Audio/Test/ContextTest.cpp | 8 +++++++- src/Magnum/GL/Test/ContextTest.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Audio/Test/ContextTest.cpp b/src/Magnum/Audio/Test/ContextTest.cpp index a2b0381b6..d5b8ef8f7 100644 --- a/src/Magnum/Audio/Test/ContextTest.cpp +++ b/src/Magnum/Audio/Test/ContextTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -84,8 +85,13 @@ void ContextTest::extensions() { CORRADE_FAIL_IF(e.index() >= Implementation::ExtensionCount, "Index" << e.index() << "larger than" << Implementation::ExtensionCount); + /* Have to use Containers::StringView to avoid passing null char* to + std::cout (which crashes on Mac due to strlen being called on it) + because the message is actually printed sooner than the condition + gets tested! */ + /** @todo clean up once fixed in Corrade */ CORRADE_FAIL_IF(used[e.index()], - "Index" << e.index() << "already used by" << used[e.index()]); + "Index" << e.index() << "already used by" << Containers::StringView{used[e.index()]}); used[e.index()] = e.string(); CORRADE_FAIL_IF(!unique.insert(e.string()).second, diff --git a/src/Magnum/GL/Test/ContextTest.cpp b/src/Magnum/GL/Test/ContextTest.cpp index 4ff1b45ef..af5c0132a 100644 --- a/src/Magnum/GL/Test/ContextTest.cpp +++ b/src/Magnum/GL/Test/ContextTest.cpp @@ -406,8 +406,13 @@ void ContextTest::extensions() { CORRADE_FAIL_IF(e.index() >= GL::Implementation::ExtensionCount, "Index" << e.index() << "larger than" << GL::Implementation::ExtensionCount); + /* Have to use Containers::StringView to avoid passing null char* + to std::cout (which crashes on Mac due to strlen being called on + it) because the message is actually printed sooner than the + condition gets tested! */ + /** @todo clean up once fixed in Corrade */ CORRADE_FAIL_IF(used[e.index()], - "Index" << e.index() << "already used by" << used[e.index()]); + "Index" << e.index() << "already used by" << Containers::StringView{used[e.index()]}); used[e.index()] = e.string(); CORRADE_FAIL_IF(!unique.insert(e.string()).second,