-
-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
533321f
commit 6e00c37
Showing
12 changed files
with
183 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}) | ||
|
||
enable_testing() | ||
|
||
set(INSTALL_GTEST OFF) | ||
|
||
# For Windows: Prevent overriding the parent project's compiler/linker settings | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # cmake-lint: disable=C0103 | ||
|
||
set(TEST_SOURCES | ||
${CMAKE_SOURCE_DIR}/tests/main.cpp | ||
${CMAKE_SOURCE_DIR}/tests/test_main.cpp | ||
) | ||
|
||
add_executable(sunshine_test ${TEST_SOURCES}) | ||
target_link_libraries(sunshine_test | ||
${SUNSHINE_TARGET_FILES} | ||
${SUNSHINE_EXTERNAL_LIBRARIES} | ||
${EXTRA_LIBS} | ||
gtest | ||
) | ||
set_target_properties(sunshine_test PROPERTIES CXX_STANDARD 17) | ||
target_compile_options(sunshine_test PRIVATE ${SUNSHINE_COMPILE_OPTIONS}) | ||
add_test(NAME sunshine_test COMMAND sunshine_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "gtest/gtest.h" | ||
|
||
int | ||
main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @file tests/test_main.cpp | ||
* @brief Test src/main.*. | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include <src/main.h> | ||
|
||
TEST(MainTestSuite, WriteFileTest) { | ||
EXPECT_EQ(write_file("write_file_test.txt", "test"), 0); | ||
} | ||
|
||
TEST(MainTestSuite, ReadFileTest) { | ||
// read file from WriteFileTest | ||
EXPECT_EQ(read_file("write_file_test.txt"), "test"); | ||
|
||
// read missing file | ||
EXPECT_EQ(read_file("non-existing-file.txt"), ""); | ||
} |
Submodule googletest
added at
f8d7d7
Oops, something went wrong.