Skip to content

Commit

Permalink
Get gtest working
Browse files Browse the repository at this point in the history
  • Loading branch information
meisZWFLZ authored and BattleCh1cken committed Nov 20, 2023
1 parent fc1ef76 commit 6f7a3bb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ temp.errors
*.zip

# Doxygen
latex
latex

# unit testing
build/
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ add_executable(LemLib
src/lemlib/pose.cpp

test/pose.cpp
src/test.cpp
)

# Link against gtest
target_link_libraries(LemLib gtest_main)

include(GoogleTest)
gtest_discover_tests(LemLib)
gtest_discover_tests(LemLib)
16 changes: 16 additions & 0 deletions CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.6)

project(external-dependencies NONE)

include(ExternalProject)

ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
8 changes: 8 additions & 0 deletions src/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <gtest/gtest.h>

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

0 comments on commit 6f7a3bb

Please sign in to comment.