9 Commits
Author SHA1 Message Date
Chris Thrasher 0066e8f352 Add tests for sfVideoMode 2024-12-22 17:37:54 -06:00
Chris Thrasher ab1a1a2299 Add tests for sfCoordinateType 2024-12-22 17:28:57 -06:00
Chris Thrasher bb8a261bb8 Add tests for sfColor 2024-12-22 17:28:57 -06:00
Chris Thrasher b3e6e23ffd Add tests for sfBlendMode 2024-12-22 17:28:57 -06:00
Chris Thrasher e46663cf38 Add tests for sfRect 2024-12-22 17:28:57 -06:00
Chris Thrasher e7a41e864f Add tests for Audio module 2024-12-22 17:05:49 -06:00
Chris Thrasher ae540e2396 Fix README typo 2024-12-22 14:58:58 -06:00
Chris Thrasher 14e06ccea4 Centrally define SFML version 2024-12-21 20:38:26 -06:00
Chris Thrasher a185b440ef Use SFML 3.0.0 tag 2024-12-21 19:08:15 -06:00
9 changed files with 500 additions and 4 deletions

No files matched your search

+6 -3
View File
@@ -6,6 +6,9 @@ concurrency:
group: environment-${{github.ref}}
cancel-in-progress: true
env:
SFML_VERSION: 3.0.0
defaults:
run:
shell: bash
@@ -49,7 +52,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: master
ref: ${{env.SFML_VERSION}}
path: SFML
- name: Configure SFML CMake
@@ -104,7 +107,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: master
ref: ${{env.SFML_VERSION}}
path: SFML
- name: Configure SFML CMake
@@ -138,7 +141,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: SFML/SFML
ref: master
ref: ${{env.SFML_VERSION}}
path: SFML
- name: Configure SFML
+1 -1
View File
@@ -9,7 +9,7 @@ SFML is a simple, fast, cross-platform and object-oriented multimedia API. It pr
Development is focused on the next major version in the `master` branch. No more features are planned for the 2.x release series.
- The [`master`](https://github.com/SFML/CSFML/tree/master) branch contains work in progress for the next major version CSFML 3. As such it's considered unstable, but any testing and feedback is highly appreciated.
- The [`2.6.1`](https://github.com/SFML/CSFML/tree/2.6.1) tag is the latest official SFML release and will be the last minor release in the 2.x series.
- The [`2.6.1`](https://github.com/SFML/CSFML/tree/2.6.1) tag is the latest official CSFML release and will be the last minor release in the 2.x series.
- The [`2.6.x`](https://github.com/SFML/CSFML/tree/2.6.x) branch contains the latest bugfix work on CSFML 2.6.x, matching SFML's `2.6.x` branch.
## Authors
+29
View File
@@ -0,0 +1,29 @@
#include <CSFML/Audio/SoundChannel.h>
#include <SFML/Audio/SoundChannel.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Audio] sfSoundChannel")
{
STATIC_CHECK(sfSoundChannelUnspecified == static_cast<int>(sf::SoundChannel::Unspecified));
STATIC_CHECK(sfSoundChannelMono == static_cast<int>(sf::SoundChannel::Mono));
STATIC_CHECK(sfSoundChannelFrontLeft == static_cast<int>(sf::SoundChannel::FrontLeft));
STATIC_CHECK(sfSoundChannelFrontRight == static_cast<int>(sf::SoundChannel::FrontRight));
STATIC_CHECK(sfSoundChannelFrontCenter == static_cast<int>(sf::SoundChannel::FrontCenter));
STATIC_CHECK(sfSoundChannelFrontLeftOfCenter == static_cast<int>(sf::SoundChannel::FrontLeftOfCenter));
STATIC_CHECK(sfSoundChannelFrontRightOfCenter == static_cast<int>(sf::SoundChannel::FrontRightOfCenter));
STATIC_CHECK(sfSoundChannelLowFrequencyEffects == static_cast<int>(sf::SoundChannel::LowFrequencyEffects));
STATIC_CHECK(sfSoundChannelBackLeft == static_cast<int>(sf::SoundChannel::BackLeft));
STATIC_CHECK(sfSoundChannelBackRight == static_cast<int>(sf::SoundChannel::BackRight));
STATIC_CHECK(sfSoundChannelBackCenter == static_cast<int>(sf::SoundChannel::BackCenter));
STATIC_CHECK(sfSoundChannelSideLeft == static_cast<int>(sf::SoundChannel::SideLeft));
STATIC_CHECK(sfSoundChannelSideRight == static_cast<int>(sf::SoundChannel::SideRight));
STATIC_CHECK(sfSoundChannelTopCenter == static_cast<int>(sf::SoundChannel::TopCenter));
STATIC_CHECK(sfSoundChannelTopFrontLeft == static_cast<int>(sf::SoundChannel::TopFrontLeft));
STATIC_CHECK(sfSoundChannelTopFrontRight == static_cast<int>(sf::SoundChannel::TopFrontRight));
STATIC_CHECK(sfSoundChannelTopFrontCenter == static_cast<int>(sf::SoundChannel::TopFrontCenter));
STATIC_CHECK(sfSoundChannelTopBackLeft == static_cast<int>(sf::SoundChannel::TopBackLeft));
STATIC_CHECK(sfSoundChannelTopBackRight == static_cast<int>(sf::SoundChannel::TopBackRight));
STATIC_CHECK(sfSoundChannelTopBackCenter == static_cast<int>(sf::SoundChannel::TopBackCenter));
}
+18
View File
@@ -37,6 +37,7 @@ add_executable(test-csfml-window
Window/Keyboard.test.cpp
Window/Mouse.test.cpp
Window/Sensor.test.cpp
Window/VideoMode.test.cpp
Window/Window.test.cpp
Window/WindowBase.test.cpp
)
@@ -44,6 +45,16 @@ target_link_libraries(test-csfml-window PRIVATE csfml-window Catch2::Catch2WithM
set_target_warnings(test-csfml-window)
catch_discover_tests(test-csfml-window)
add_executable(test-csfml-graphics
Graphics/BlendMode.test.cpp
Graphics/Color.test.cpp
Graphics/CoordinateType.test.cpp
Graphics/Rect.test.cpp
)
target_link_libraries(test-csfml-graphics PRIVATE csfml-graphics Catch2::Catch2WithMain SFML::Graphics)
set_target_warnings(test-csfml-graphics)
catch_discover_tests(test-csfml-graphics)
add_executable(test-csfml-network
Network/Ftp.test.cpp
Network/Http.test.cpp
@@ -54,6 +65,13 @@ target_link_libraries(test-csfml-network PRIVATE csfml-network Catch2::Catch2Wit
set_target_warnings(test-csfml-network)
catch_discover_tests(test-csfml-network)
add_executable(test-csfml-audio
Audio/SoundChannel.test.cpp
)
target_link_libraries(test-csfml-audio PRIVATE csfml-audio Catch2::Catch2WithMain SFML::Audio)
set_target_warnings(test-csfml-audio)
catch_discover_tests(test-csfml-audio)
# Copy DLLs into the same directory
if(SFML_OS_WINDOWS AND NOT CSFML_LINK_SFML_STATICALLY)
foreach(SFML_TARGET SFML::System SFML::Window SFML::Graphics SFML::Audio SFML::Network)
+112
View File
@@ -0,0 +1,112 @@
#include <CSFML/Graphics/BlendMode.h>
#include <SFML/Graphics/BlendMode.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfBlendMode")
{
SECTION("sfBlendFactor")
{
STATIC_CHECK(sfBlendFactorZero == static_cast<int>(sf::BlendMode::Factor::Zero));
STATIC_CHECK(sfBlendFactorOne == static_cast<int>(sf::BlendMode::Factor::One));
STATIC_CHECK(sfBlendFactorSrcColor == static_cast<int>(sf::BlendMode::Factor::SrcColor));
STATIC_CHECK(sfBlendFactorOneMinusSrcColor == static_cast<int>(sf::BlendMode::Factor::OneMinusSrcColor));
STATIC_CHECK(sfBlendFactorDstColor == static_cast<int>(sf::BlendMode::Factor::DstColor));
STATIC_CHECK(sfBlendFactorOneMinusDstColor == static_cast<int>(sf::BlendMode::Factor::OneMinusDstColor));
STATIC_CHECK(sfBlendFactorSrcAlpha == static_cast<int>(sf::BlendMode::Factor::SrcAlpha));
STATIC_CHECK(sfBlendFactorOneMinusSrcAlpha == static_cast<int>(sf::BlendMode::Factor::OneMinusSrcAlpha));
STATIC_CHECK(sfBlendFactorDstAlpha == static_cast<int>(sf::BlendMode::Factor::DstAlpha));
STATIC_CHECK(sfBlendFactorOneMinusDstAlpha == static_cast<int>(sf::BlendMode::Factor::OneMinusDstAlpha));
}
SECTION("sfBlendEquation")
{
STATIC_CHECK(sfBlendEquationAdd == static_cast<int>(sf::BlendMode::Equation::Add));
STATIC_CHECK(sfBlendEquationSubtract == static_cast<int>(sf::BlendMode::Equation::Subtract));
STATIC_CHECK(sfBlendEquationReverseSubtract == static_cast<int>(sf::BlendMode::Equation::ReverseSubtract));
STATIC_CHECK(sfBlendEquationMin == static_cast<int>(sf::BlendMode::Equation::Min));
STATIC_CHECK(sfBlendEquationMax == static_cast<int>(sf::BlendMode::Equation::Max));
}
SECTION("Construction")
{
// sfBlendFactor colorSrcFactor; ///< Source blending factor for the color channels
// sfBlendFactor colorDstFactor; ///< Destination blending factor for the color channels
// sfBlendEquation colorEquation; ///< Blending equation for the color channels
// sfBlendFactor alphaSrcFactor; ///< Source blending factor for the alpha channel
// sfBlendFactor alphaDstFactor; ///< Destination blending factor for the alpha channel
// sfBlendEquation alphaEquation; ///< Blending equation for the alpha channel
constexpr sfBlendMode blendMode{};
STATIC_CHECK(blendMode.colorSrcFactor == sfBlendFactorZero);
STATIC_CHECK(blendMode.colorDstFactor == sfBlendFactorZero);
STATIC_CHECK(blendMode.colorEquation == sfBlendEquationAdd);
STATIC_CHECK(blendMode.alphaSrcFactor == sfBlendFactorZero);
STATIC_CHECK(blendMode.alphaDstFactor == sfBlendFactorZero);
STATIC_CHECK(blendMode.alphaEquation == sfBlendEquationAdd);
}
SECTION("Constants")
{
SECTION("sfBlendAlpha")
{
CHECK(sfBlendAlpha.colorSrcFactor == sfBlendFactorSrcAlpha);
CHECK(sfBlendAlpha.colorDstFactor == sfBlendFactorOneMinusSrcAlpha);
CHECK(sfBlendAlpha.colorEquation == sfBlendEquationAdd);
CHECK(sfBlendAlpha.alphaSrcFactor == sfBlendFactorOne);
CHECK(sfBlendAlpha.alphaDstFactor == sfBlendFactorOneMinusSrcAlpha);
CHECK(sfBlendAlpha.alphaEquation == sfBlendEquationAdd);
}
SECTION("sfBlendAdd")
{
CHECK(sfBlendAdd.colorSrcFactor == sfBlendFactorSrcAlpha);
CHECK(sfBlendAdd.colorDstFactor == sfBlendFactorOne);
CHECK(sfBlendAdd.colorEquation == sfBlendEquationAdd);
CHECK(sfBlendAdd.alphaSrcFactor == sfBlendFactorOne);
CHECK(sfBlendAdd.alphaDstFactor == sfBlendFactorOne);
CHECK(sfBlendAdd.alphaEquation == sfBlendEquationAdd);
}
SECTION("sfBlendMultiply")
{
CHECK(sfBlendMultiply.colorSrcFactor == sfBlendFactorDstColor);
CHECK(sfBlendMultiply.colorDstFactor == sfBlendFactorZero);
CHECK(sfBlendMultiply.colorEquation == sfBlendEquationAdd);
CHECK(sfBlendMultiply.alphaSrcFactor == sfBlendFactorDstColor);
CHECK(sfBlendMultiply.alphaDstFactor == sfBlendFactorZero);
CHECK(sfBlendMultiply.alphaEquation == sfBlendEquationAdd);
}
SECTION("sfBlendMin")
{
CHECK(sfBlendMin.colorSrcFactor == sfBlendFactorOne);
CHECK(sfBlendMin.colorDstFactor == sfBlendFactorOne);
CHECK(sfBlendMin.colorEquation == sfBlendEquationMin);
CHECK(sfBlendMin.alphaSrcFactor == sfBlendFactorOne);
CHECK(sfBlendMin.alphaDstFactor == sfBlendFactorOne);
CHECK(sfBlendMin.alphaEquation == sfBlendEquationMin);
}
SECTION("sfBlendMax")
{
CHECK(sfBlendMax.colorSrcFactor == sfBlendFactorOne);
CHECK(sfBlendMax.colorDstFactor == sfBlendFactorOne);
CHECK(sfBlendMax.colorEquation == sfBlendEquationMax);
CHECK(sfBlendMax.alphaSrcFactor == sfBlendFactorOne);
CHECK(sfBlendMax.alphaDstFactor == sfBlendFactorOne);
CHECK(sfBlendMax.alphaEquation == sfBlendEquationMax);
}
SECTION("sfBlendNone")
{
CHECK(sfBlendNone.colorSrcFactor == sfBlendFactorOne);
CHECK(sfBlendNone.colorDstFactor == sfBlendFactorZero);
CHECK(sfBlendNone.colorEquation == sfBlendEquationAdd);
CHECK(sfBlendNone.alphaSrcFactor == sfBlendFactorOne);
CHECK(sfBlendNone.alphaDstFactor == sfBlendFactorZero);
CHECK(sfBlendNone.alphaEquation == sfBlendEquationAdd);
}
}
}
+229
View File
@@ -0,0 +1,229 @@
#include <CSFML/Graphics/Color.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfColor")
{
SECTION("Construction")
{
constexpr sfColor color{};
STATIC_CHECK(color.r == 0);
STATIC_CHECK(color.g == 0);
STATIC_CHECK(color.b == 0);
STATIC_CHECK(color.a == 0);
}
SECTION("Constants")
{
SECTION("sfBlack")
{
CHECK(sfBlack.r == 0);
CHECK(sfBlack.g == 0);
CHECK(sfBlack.b == 0);
CHECK(sfBlack.a == 255);
}
SECTION("sfWhite")
{
CHECK(sfWhite.r == 255);
CHECK(sfWhite.g == 255);
CHECK(sfWhite.b == 255);
CHECK(sfWhite.a == 255);
}
SECTION("sfRed")
{
CHECK(sfRed.r == 255);
CHECK(sfRed.g == 0);
CHECK(sfRed.b == 0);
CHECK(sfRed.a == 255);
}
SECTION("sfGreen")
{
CHECK(sfGreen.r == 0);
CHECK(sfGreen.g == 255);
CHECK(sfGreen.b == 0);
CHECK(sfGreen.a == 255);
}
SECTION("sfBlue")
{
CHECK(sfBlue.r == 0);
CHECK(sfBlue.g == 0);
CHECK(sfBlue.b == 255);
CHECK(sfBlue.a == 255);
}
SECTION("sfYellow")
{
CHECK(sfYellow.r == 255);
CHECK(sfYellow.g == 255);
CHECK(sfYellow.b == 0);
CHECK(sfYellow.a == 255);
}
SECTION("sfMagenta")
{
CHECK(sfMagenta.r == 255);
CHECK(sfMagenta.g == 0);
CHECK(sfMagenta.b == 255);
CHECK(sfMagenta.a == 255);
}
SECTION("sfCyan")
{
CHECK(sfCyan.r == 0);
CHECK(sfCyan.g == 255);
CHECK(sfCyan.b == 255);
CHECK(sfCyan.a == 255);
}
SECTION("sfTransparent")
{
CHECK(sfTransparent.r == 0);
CHECK(sfTransparent.g == 0);
CHECK(sfTransparent.b == 0);
CHECK(sfTransparent.a == 0);
}
}
SECTION("sfColor_fromRGB")
{
const sfColor color = sfColor_fromRGB(1, 2, 3);
CHECK(color.r == 1);
CHECK(color.g == 2);
CHECK(color.b == 3);
CHECK(color.a == 255);
}
SECTION("sfColor_fromRGBA")
{
const sfColor color = sfColor_fromRGBA(4, 5, 6, 7);
CHECK(color.r == 4);
CHECK(color.g == 5);
CHECK(color.b == 6);
CHECK(color.a == 7);
}
SECTION("sfColor_fromInteger")
{
sfColor color = sfColor_fromInteger(0);
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_fromInteger(1'000);
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 3);
CHECK(color.a == 232);
color = sfColor_fromInteger(1'000'000);
CHECK(color.r == 0);
CHECK(color.g == 15);
CHECK(color.b == 66);
CHECK(color.a == 64);
color = sfColor_fromInteger(1'000'000'000);
CHECK(color.r == 59);
CHECK(color.g == 154);
CHECK(color.b == 202);
CHECK(color.a == 0);
color = sfColor_fromInteger(std::numeric_limits<std::uint32_t>::max());
CHECK(color.r == 255);
CHECK(color.g == 255);
CHECK(color.b == 255);
CHECK(color.a == 255);
}
SECTION("sfColor_toInteger")
{
CHECK(sfColor_toInteger(sfBlack) == 255);
CHECK(sfColor_toInteger(sfWhite) == 4'294'967'295);
CHECK(sfColor_toInteger(sfRed) == 4'278'190'335);
CHECK(sfColor_toInteger(sfGreen) == 16'711'935);
CHECK(sfColor_toInteger(sfBlue) == 65'535);
CHECK(sfColor_toInteger(sfYellow) == 4'294'902'015);
CHECK(sfColor_toInteger(sfMagenta) == 4'278'255'615);
CHECK(sfColor_toInteger(sfYellow) == 4'294'902'015);
CHECK(sfColor_toInteger(sfTransparent) == 0);
}
SECTION("sfColor_add")
{
sfColor color = sfColor_add({}, {});
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_add({1, 2, 3, 4}, {5, 6, 7, 8});
CHECK(color.r == 6);
CHECK(color.g == 8);
CHECK(color.b == 10);
CHECK(color.a == 12);
color = sfColor_add({10, 20, 30, 40}, {200, 210, 220, 230});
CHECK(color.r == 210);
CHECK(color.g == 230);
CHECK(color.b == 250);
CHECK(color.a == 255);
color = sfColor_add({255, 255, 255, 255}, {255, 255, 255, 25});
CHECK(color.r == 255);
CHECK(color.g == 255);
CHECK(color.b == 255);
CHECK(color.a == 255);
}
SECTION("sfColor_subtract")
{
sfColor color = sfColor_subtract({}, {});
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_subtract({}, {10, 20, 30, 40});
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_subtract({100, 90, 80, 70}, {30, 40, 50, 60});
CHECK(color.r == 70);
CHECK(color.g == 50);
CHECK(color.b == 30);
CHECK(color.a == 10);
}
SECTION("sfColor_modulate")
{
sfColor color = sfColor_modulate({}, {});
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_modulate({}, {1, 2, 3, 4});
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_modulate({5, 6, 7, 8}, {1, 2, 3, 4});
CHECK(color.r == 0);
CHECK(color.g == 0);
CHECK(color.b == 0);
CHECK(color.a == 0);
color = sfColor_modulate({128, 196, 216, 255}, {0, 128, 255, 128});
CHECK(color.r == 0);
CHECK(color.g == 98);
CHECK(color.b == 216);
CHECK(color.a == 128);
}
}
+11
View File
@@ -0,0 +1,11 @@
#include <CSFML/Graphics/CoordinateType.h>
#include <SFML/Graphics/CoordinateType.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfCoordinateType")
{
STATIC_CHECK(sfCoordinateTypeNormalized == static_cast<int>(sf::CoordinateType::Normalized));
STATIC_CHECK(sfCoordinateTypePixels == static_cast<int>(sf::CoordinateType::Pixels));
}
+56
View File
@@ -0,0 +1,56 @@
#include <CSFML/Graphics/Rect.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Graphics] sfRect")
{
SECTION("Construction")
{
SECTION("float")
{
const sfFloatRect rect{};
CHECK(rect.position.x == 0.f);
CHECK(rect.position.y == 0.f);
CHECK(rect.size.x == 0.f);
CHECK(rect.size.y == 0.f);
}
SECTION("int")
{
const sfFloatRect rect{};
CHECK(rect.position.x == 0);
CHECK(rect.position.y == 0);
CHECK(rect.size.x == 0);
CHECK(rect.size.y == 0);
}
}
SECTION("contains(Vector2)")
{
SECTION("float")
{
const sfFloatRect rect{{0, 0}, {10, 10}};
CHECK(sfFloatRect_contains(&rect, {0, 0}));
CHECK(sfFloatRect_contains(&rect, {9, 0}));
CHECK(sfFloatRect_contains(&rect, {0, 9}));
CHECK(sfFloatRect_contains(&rect, {9, 9}));
CHECK(!sfFloatRect_contains(&rect, {9, 10}));
CHECK(!sfFloatRect_contains(&rect, {10, 9}));
CHECK(!sfFloatRect_contains(&rect, {10, 10}));
CHECK(!sfFloatRect_contains(&rect, {15, 15}));
}
SECTION("int")
{
const sfIntRect rect{{0, 0}, {10, 10}};
CHECK(sfIntRect_contains(&rect, {0, 0}));
CHECK(sfIntRect_contains(&rect, {9, 0}));
CHECK(sfIntRect_contains(&rect, {0, 9}));
CHECK(sfIntRect_contains(&rect, {9, 9}));
CHECK(!sfIntRect_contains(&rect, {9, 10}));
CHECK(!sfIntRect_contains(&rect, {10, 9}));
CHECK(!sfIntRect_contains(&rect, {10, 10}));
CHECK(!sfIntRect_contains(&rect, {15, 15}));
}
}
}
+38
View File
@@ -0,0 +1,38 @@
#include <CSFML/Window/VideoMode.h>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Window] sfVideoMode")
{
SECTION("Construction")
{
const sfVideoMode videoMode{};
CHECK(videoMode.size.x == 0);
CHECK(videoMode.size.y == 0);
CHECK(videoMode.bitsPerPixel == 0);
}
SECTION("sfVideoMode_getDesktopMode()")
{
const sfVideoMode videoMode = sfVideoMode_getDesktopMode();
CHECK(videoMode.size.x != 0);
CHECK(videoMode.size.y != 0);
CHECK(videoMode.bitsPerPixel != 0);
}
SECTION("sfVideoMode_getFullscreenModes()")
{
std::size_t count = 0;
const sfVideoMode* videoModes = sfVideoMode_getFullscreenModes(&count);
REQUIRE(count > 0);
const sfVideoMode& videoMode = videoModes[0];
CHECK(videoMode.size.x != 0);
CHECK(videoMode.size.y != 0);
CHECK(videoMode.bitsPerPixel != 0);
}
SECTION("sfVideoMode_isValid")
{
CHECK(!sfVideoMode_isValid({}));
}
}