Skip to content

Commit

Permalink
gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuOfficial committed Apr 1, 2024
1 parent 3a1541a commit f980fd1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
path = lib/cpr
url = https://github.com/libcpr/cpr.git
branch = 1.9.x
[submodule "lib/gtest"]
path = lib/gtest
url = https://github.com/google/googletest.git
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ endif()
add_compile_definitions(API_MICROSOFT_CLIENT_ID="${API_MICROSOFT_CLIENT_ID}")
add_compile_definitions(DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID})

enable_testing()
include(CTest)

add_subdirectory(lib/json-c)
add_subdirectory(lib/cpr)
add_subdirectory(lib/libarchive)
add_subdirectory(lib/gtest)

add_subdirectory(src)
1 change: 1 addition & 0 deletions lib/gtest
Submodule gtest added at 77afe8
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(core)
add_subdirectory(ui)
add_subdirectory(tests)
7 changes: 7 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (BUILD_TESTING)
add_executable(BetacraftTests test.cpp)
target_link_libraries(BetacraftTests PRIVATE GTest::gtest_main)

include(GoogleTest)
gtest_discover_tests(BetacraftTests)
endif()
14 changes: 14 additions & 0 deletions src/tests/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <gtest/gtest.h>

namespace {
int GetMeaningOfLife() { return 42; }
}

TEST(TestTopic, TrivialEquality) {
EXPECT_EQ(GetMeaningOfLife(), 42);
}

TEST(TestTopic, MoreEqualityTests) {
ASSERT_EQ(GetMeaningOfLife(), 0) << "Oh no, a mistake!";
EXPECT_FLOAT_EQ(23.23f, 23.23f);
}

0 comments on commit f980fd1

Please sign in to comment.