Add tests for sfSocketStatus

This commit is contained in:
Chris Thrasher committed 2024-09-02 20:04:06 -06:00
1 parent 84978f8acc
commit 10aaee1290
5 files changed
+36 -22

No files matched your search

+20
View File
@@ -60,6 +60,26 @@ if(SFML_OS_WINDOWS)
endif()
endif()
# find SFML libraries (C++)
if(CSFML_LINK_SFML_STATICALLY)
set(SFML_STATIC_LIBRARIES TRUE)
add_definitions(-DSFML_STATIC)
endif()
set(SFML_MODULES "System")
if(CSFML_BUILD_AUDIO)
list(PREPEND SFML_MODULES "Audio")
endif()
if(CSFML_BUILD_GRAPHICS)
list(PREPEND SFML_MODULES "Graphics")
endif()
if(CSFML_BUILD_WINDOW)
list(PREPEND SFML_MODULES "Window")
endif()
if(CSFML_BUILD_NETWORK)
list(PREPEND SFML_MODULES "Network")
endif()
find_package(SFML 3.0.0 COMPONENTS ${SFML_MODULES} REQUIRED)
# add the subdirectories
add_subdirectory(src/CSFML)
if(CSFML_BUILD_DOC)
-1
View File
@@ -35,5 +35,4 @@ typedef enum
sfSocketPartial, ///< The socket sent a part of the data
sfSocketDisconnected, ///< The TCP socket has been disconnected
sfSocketError ///< An unexpected error happened
} sfSocketStatus;
-20
View File
@@ -16,26 +16,6 @@ if(SFML_COMPILER_MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# find SFML libraries (C++)
if(CSFML_LINK_SFML_STATICALLY)
set(SFML_STATIC_LIBRARIES TRUE)
add_definitions(-DSFML_STATIC)
endif()
set(SFML_MODULES "System")
if(CSFML_BUILD_AUDIO)
list(PREPEND SFML_MODULES "Audio")
endif()
if(CSFML_BUILD_GRAPHICS)
list(PREPEND SFML_MODULES "Graphics")
endif()
if(CSFML_BUILD_WINDOW)
list(PREPEND SFML_MODULES "Window")
endif()
if(CSFML_BUILD_NETWORK)
list(PREPEND SFML_MODULES "Network")
endif()
find_package(SFML 3.0.0 COMPONENTS ${SFML_MODULES} REQUIRED)
# add the modules subdirectories
add_subdirectory(System)
+2 -1
View File
@@ -41,8 +41,9 @@ catch_discover_tests(test-csfml-window)
add_executable(test-csfml-network
Network/IpAddress.test.cpp
Network/SocketStatus.test.cpp
)
target_link_libraries(test-csfml-network PRIVATE csfml-network Catch2::Catch2WithMain)
target_link_libraries(test-csfml-network PRIVATE csfml-network Catch2::Catch2WithMain SFML::Network)
set_target_warnings(test-csfml-network)
catch_discover_tests(test-csfml-network)
+14
View File
@@ -0,0 +1,14 @@
#include <CSFML/Network/SocketStatus.h>
#include <SFML/Network/Socket.hpp>
#include <catch2/catch_test_macros.hpp>
TEST_CASE("[Network] sfSocketStatus")
{
STATIC_CHECK(sfSocketDone == static_cast<int>(sf::Socket::Status::Done));
STATIC_CHECK(sfSocketNotReady == static_cast<int>(sf::Socket::Status::NotReady));
STATIC_CHECK(sfSocketPartial == static_cast<int>(sf::Socket::Status::Partial));
STATIC_CHECK(sfSocketDisconnected == static_cast<int>(sf::Socket::Status::Disconnected));
STATIC_CHECK(sfSocketError == static_cast<int>(sf::Socket::Status::Error));
}