Browse Source

GL: add unit test for Platform::GLContext{NoCreate, ...}

pull/332/head
Max Schwarz 7 years ago committed by Vladimír Vondruš
parent
commit
f58c26c66d
  1. 18
      src/Magnum/GL/Test/ContextTest.cpp

18
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<Context, const Context&>{}));

Loading…
Cancel
Save