Browse Source

GL: the compiler outsmarted me and made my test fail.

euler-xxx
Vladimír Vondruš 5 years ago
parent
commit
5714828e0a
  1. 24
      src/Magnum/GL/Test/ContextTest.cpp

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

@ -36,6 +36,8 @@
namespace Magnum { namespace GL { namespace Test { namespace { namespace Magnum { namespace GL { namespace Test { namespace {
using namespace Containers::Literals;
struct ContextTest: TestSuite::Tester { struct ContextTest: TestSuite::Tester {
explicit ContextTest(); explicit ContextTest();
@ -141,20 +143,24 @@ void ContextTest::isExtension() {
} }
void ContextTest::configurationConstruct() { void ContextTest::configurationConstruct() {
/* In order to verify the string literals get properly interned I could
make them non-global (by converting from const char*) and then test that
they are global and with a different pointer. However, compilers are
clever and on static builds they could just deduplicate the literals,
which would cause this test to fail. Instead I make them
non-null-terminated which blocks the compiler from combining them
together. */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const Containers::StringView a = "no-layout-qualifiers-on-old-glsl"; const Containers::StringView a = "no-layout-qualifiers-on-old-glsl!"_s.except(1);
const Containers::StringView b = "nv-compressed-block-size-in-bits"; const Containers::StringView b = "nv-compressed-block-size-in-bits!"_s.except(1);
const Containers::StringView c = "nv-cubemap-inconsistent-compressed-image-size"; const Containers::StringView c = "nv-cubemap-inconsistent-compressed-image-size!"_s.except(1);
#elif !defined(MAGNUM_TARGET_WEBGL) #elif !defined(MAGNUM_TARGET_WEBGL)
const Containers::StringView a = "swiftshader-no-empty-egl-context-flags"; const Containers::StringView a = "swiftshader-no-empty-egl-context-flags!"_s.except(1);
const Containers::StringView b = "swiftshader-egl-context-needs-pbuffer"; const Containers::StringView b = "swiftshader-egl-context-needs-pbuffer!"_s.except(1);
const Containers::StringView c = "angle-chatty-shader-compiler"; const Containers::StringView c = "angle-chatty-shader-compiler!"_s.except(1);
#else #else
/* No general WebGL workarounds to test */ /* No general WebGL workarounds to test */
#endif #endif
/* Deliberately not having the literals global to test that they get
converted to something else */
CORRADE_VERIFY(!(a.flags() & Containers::StringViewFlag::Global));
Context::Configuration configuration; Context::Configuration configuration;
configuration configuration

Loading…
Cancel
Save