mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
chore: initial commit
This commit is contained in:
commit
69a95ae405
28 changed files with 18574 additions and 0 deletions
31
test/CMakeLists.txt
Normal file
31
test/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
file(GLOB_RECURSE TEST_SOURCES "*.cpp")
|
||||
|
||||
if(WHOA_SYSTEM_MAC)
|
||||
set_source_files_properties(${TEST_SOURCES}
|
||||
PROPERTIES COMPILE_FLAGS "-x objective-c++"
|
||||
)
|
||||
|
||||
add_executable(CommonTest ${TEST_SOURCES})
|
||||
|
||||
target_link_libraries(CommonTest
|
||||
PRIVATE
|
||||
common
|
||||
"-framework AppKit"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WHOA_SYSTEM_LINUX OR WHOA_SYSTEM_WIN)
|
||||
add_executable(CommonTest ${TEST_SOURCES})
|
||||
|
||||
target_link_libraries(CommonTest
|
||||
PRIVATE
|
||||
common
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(CommonTest
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
install(TARGETS CommonTest DESTINATION "bin")
|
||||
34
test/String.cpp
Normal file
34
test/String.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "common/String.hpp"
|
||||
#include "test/Test.hpp"
|
||||
#include <storm/String.hpp>
|
||||
|
||||
TEST_CASE("RCString::Copy", "[string]") {
|
||||
SECTION("copies source string") {
|
||||
auto str = "foo";
|
||||
RCString rcStr;
|
||||
rcStr.Copy(str);
|
||||
REQUIRE(!SStrCmp(str, rcStr.GetString(), STORM_MAX_STR));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("RCString::GetString", "[string]") {
|
||||
SECTION("returns identical pointers for identical source strings") {
|
||||
auto str1 = "foo";
|
||||
auto str2 = "foo";
|
||||
RCString rcStr1;
|
||||
rcStr1.Copy(str1);
|
||||
RCString rcStr2;
|
||||
rcStr2.Copy(str2);
|
||||
REQUIRE(rcStr1.GetString() == rcStr2.GetString());
|
||||
}
|
||||
|
||||
SECTION("returns different pointers for different source strings") {
|
||||
auto str1 = "foo1";
|
||||
auto str2 = "foo2";
|
||||
RCString rcStr1;
|
||||
rcStr1.Copy(str1);
|
||||
RCString rcStr2;
|
||||
rcStr2.Copy(str2);
|
||||
REQUIRE(rcStr1.GetString() != rcStr2.GetString());
|
||||
}
|
||||
}
|
||||
2
test/Test.cpp
Normal file
2
test/Test.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include "test/Test.hpp"
|
||||
1
test/Test.hpp
Normal file
1
test/Test.hpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "vendor/catch-2.13.10/catch.hpp"
|
||||
Loading…
Add table
Add a link
Reference in a new issue