Skip to content

Commit

Permalink
added gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz126 committed Feb 20, 2024
1 parent 7336b33 commit 0684305
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ env:
BUILD_TYPE: Release
BUILD_PATH: ${{github.workspace}}/communicator/build
SOURCE: ${{github.workspace}}/communicator
TEST_BUILD_PATH: ${{github.workspace}}/communicator/tests/build


jobs:
build:
Expand Down Expand Up @@ -41,8 +43,7 @@ jobs:
- name: Pre-commit actions
uses: pre-commit/[email protected]

# TODO uncomment when tests are added
# - name: Test
# working-directory: ${{env.BUILD_PATH}}
# run: ctest -C ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{env.TEST_BUILD_PATH}}
run: ctest -C ${{env.BUILD_TYPE}}

18 changes: 18 additions & 0 deletions communicator/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.5)
project(CommunicatorGTest)

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Now simply link against gtest or gtest_main as needed. Eg
add_executable(example-gt exampleTest.cpp)
target_link_libraries(example-gt gtest_main)
enable_testing()
add_test(NAME example_test COMMAND example-gt)
9 changes: 9 additions & 0 deletions communicator/tests/exampleTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "gtest/gtest.h"

// Demonstrate some basic assertions.
TEST(exampleTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}

0 comments on commit 0684305

Please sign in to comment.