From 4e2f6ae655e224b67e4721b99fd52d7f16f49442 Mon Sep 17 00:00:00 2001 From: Chris Thrasher <chrisjthrasher@gmail.com> Date: Sun, 24 Sep 2023 21:32:17 -0600 Subject: [PATCH] Add more tests for `sf::Context` --- test/Window/Context.test.cpp | 37 ++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/test/Window/Context.test.cpp b/test/Window/Context.test.cpp index 070f7c14e..8fd6719a1 100644 --- a/test/Window/Context.test.cpp +++ b/test/Window/Context.test.cpp @@ -28,20 +28,45 @@ TEST_CASE("[Window] sf::Context", runDisplayTests()) SECTION("Construction") { const sf::Context context; - CHECK(context.getSettings().majorVersion > 0); + CHECK(context.getActiveContext() == &context); + CHECK(context.getActiveContextId() != 0); + } + + SECTION("setActive()") + { + sf::Context context; + CHECK(context.setActive(false)); + CHECK(context.getActiveContext() == nullptr); + CHECK(context.getActiveContextId() == 0); + CHECK(context.setActive(true)); + CHECK(context.getActiveContext() == &context); + CHECK(context.getActiveContextId() != 0); + } + + SECTION("getActiveContext()/getActiveContextId()") + { + CHECK(sf::Context::getActiveContext() == nullptr); + CHECK(sf::Context::getActiveContextId() == 0); + + { + const sf::Context context; + CHECK(context.getSettings().majorVersion > 0); + CHECK(sf::Context::getActiveContext() == &context); + CHECK(sf::Context::getActiveContextId() != 0); + } + + CHECK(sf::Context::getActiveContext() == nullptr); + CHECK(sf::Context::getActiveContextId() == 0); } SECTION("Version String") { sf::Context context; - CHECK(context.setActive(true)); - using glGetStringFuncType = const char*(GLAPI*)(unsigned int); - - auto glGetStringFunc = reinterpret_cast<glGetStringFuncType>(sf::Context::getFunction("glGetString")); - + using glGetStringFuncType = const char*(GLAPI*)(unsigned int); + const auto glGetStringFunc = reinterpret_cast<glGetStringFuncType>(sf::Context::getFunction("glGetString")); REQUIRE(glGetStringFunc); constexpr unsigned int glVendor = 0x1F00;