mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 07:43:01 +01:00
Write platform tests
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
# include "../OpenRCT2.h"
|
||||
# include "../Version.h"
|
||||
# include "../config/Config.h"
|
||||
# include "../core/String.h"
|
||||
# include "../localisation/Date.h"
|
||||
# include "../localisation/Language.h"
|
||||
# include "../rct2/RCT2.h"
|
||||
@@ -268,6 +269,8 @@ std::string platform_sanitise_filename(const std::string& path)
|
||||
},
|
||||
'_');
|
||||
|
||||
sanitised = String::Trim(sanitised);
|
||||
|
||||
return sanitised;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,13 @@ target_link_libraries(test_ini ${GTEST_LIBRARIES} test-common ${LDL} z)
|
||||
target_link_platform_libraries(test_ini)
|
||||
add_test(NAME ini COMMAND test_ini)
|
||||
|
||||
# Platform
|
||||
add_executable(test_platform ${CMAKE_CURRENT_LIST_DIR}/Platform.cpp)
|
||||
SET_CHECK_CXX_FLAGS(test_platform)
|
||||
target_link_libraries(test_platform ${GTEST_LIBRARIES} test-common ${LDL} z libopenrct2)
|
||||
target_link_platform_libraries(test_platform)
|
||||
add_test(NAME platform COMMAND test_platform)
|
||||
|
||||
# String test
|
||||
set(STRING_TEST_SOURCES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/StringTest.cpp"
|
||||
|
||||
30
test/tests/Platform.cpp
Normal file
30
test/tests/Platform.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <openrct2/platform/platform.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(platform, sanitise_filename)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
ASSERT_EQ("normal-filename.png", platform_sanitise_filename("normal-filename.png"));
|
||||
ASSERT_EQ("utf🎱", platform_sanitise_filename("utf🎱"));
|
||||
ASSERT_EQ("forbidden_char", platform_sanitise_filename("forbidden/char"));
|
||||
ASSERT_EQ("forbidden_\\:\"|?*chars", platform_sanitise_filename("forbidden/\\:\"|?*chars"));
|
||||
ASSERT_EQ(" non trimmed ", platform_sanitise_filename(" non trimmed "));
|
||||
#else
|
||||
ASSERT_EQ("normal-filename.png", platform_sanitise_filename("normal-filename.png"));
|
||||
ASSERT_EQ("utf🎱", platform_sanitise_filename("utf🎱"));
|
||||
ASSERT_EQ("forbidden_char", platform_sanitise_filename("forbidden/char"));
|
||||
ASSERT_EQ("forbidden_______chars", platform_sanitise_filename("forbidden/\\:\"|?*chars"));
|
||||
ASSERT_EQ("non trimmed", platform_sanitise_filename(" non trimmed "));
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user