diff --git a/src/Magnum/GL/Test/ContextTest.cpp b/src/Magnum/GL/Test/ContextTest.cpp index 4ef6811bd..ea28362e2 100644 --- a/src/Magnum/GL/Test/ContextTest.cpp +++ b/src/Magnum/GL/Test/ContextTest.cpp @@ -34,6 +34,7 @@ namespace Magnum { namespace GL { namespace Test { namespace { struct ContextTest: TestSuite::Tester { explicit ContextTest(); + void constructNoCreate(); void constructCopyMove(); void extensions(); @@ -46,7 +47,8 @@ struct ContextTest: TestSuite::Tester { }; ContextTest::ContextTest() { - addTests({&ContextTest::constructCopyMove, + addTests({&ContextTest::constructNoCreate, + &ContextTest::constructCopyMove, &ContextTest::extensions, @@ -57,6 +59,20 @@ ContextTest::ContextTest() { &ContextTest::debugDetectedDrivers}); } +void ContextTest::constructNoCreate() { + { + /* Shouldn't crash during construction, shouldn't attempt to access GL, + shouldn't crash when destructing */ + struct MyContext: Context { + explicit MyContext(): Context{NoCreate, 0, nullptr, nullptr} {} + } context; + + CORRADE_VERIFY(!Context::hasCurrent()); + } + + CORRADE_VERIFY(!Context::hasCurrent()); +} + void ContextTest::constructCopyMove() { /* Only move-construction allowed */ CORRADE_VERIFY(!(std::is_constructible{}));