-
-
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
da4bd6c
commit 43df3dc
Showing
12 changed files
with
182 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,23 @@ | ||
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) | ||
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.