From 871c021a75e3d728e96086f04f7ffdf61ebd83cb Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Tue, 11 Jan 2022 20:17:15 -0700 Subject: [PATCH] Add tests for sf::ContextSettings --- test/CMakeLists.txt | 1 + test/Window/ContextSettings.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/Window/ContextSettings.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 936fb5d4..fe8e743a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(test-sfml-system PRIVATE sfml-test-main) if(SFML_BUILD_WINDOW) SET(WINDOW_SRC + "${SRCROOT}/Window/ContextSettings.cpp" "${SRCROOT}/Window/VideoMode.cpp" "${SRCROOT}/TestUtilities/WindowUtil.hpp" "${SRCROOT}/TestUtilities/WindowUtil.cpp" diff --git a/test/Window/ContextSettings.cpp b/test/Window/ContextSettings.cpp new file mode 100644 index 00000000..fe861eec --- /dev/null +++ b/test/Window/ContextSettings.cpp @@ -0,0 +1,33 @@ +#include + +#include + +TEST_CASE("sf::ContextSettings class - [window]") +{ + SUBCASE("Construction") + { + SUBCASE("Default constructor") + { + const sf::ContextSettings contextSettings; + CHECK(contextSettings.depthBits == 0); + CHECK(contextSettings.stencilBits == 0); + CHECK(contextSettings.antialiasingLevel == 0); + CHECK(contextSettings.majorVersion == 1); + CHECK(contextSettings.minorVersion == 1); + CHECK(contextSettings.attributeFlags == sf::ContextSettings::Default); + CHECK(contextSettings.sRgbCapable == false); + } + + SUBCASE("Verbose constructor") + { + const sf::ContextSettings contextSettings(1, 1, 2, 3, 5, sf::ContextSettings::Core, true); + CHECK(contextSettings.depthBits == 1); + CHECK(contextSettings.stencilBits == 1); + CHECK(contextSettings.antialiasingLevel == 2); + CHECK(contextSettings.majorVersion == 3); + CHECK(contextSettings.minorVersion == 5); + CHECK(contextSettings.attributeFlags == sf::ContextSettings::Core); + CHECK(contextSettings.sRgbCapable == true); + } + } +}