Skip to content

Commit 1b30f42

Browse files
seanmakesgamesFayti1703
authored andcommitted
googletest 'hello test'
1 parent 16292bd commit 1b30f42

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

test/gtest/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CMakeLists.txt.user
2+
CMakeCache.txt
3+
CMakeFiles
4+
CMakeScripts
5+
Testing
6+
Makefile
7+
cmake_install.cmake
8+
install_manifest.txt
9+
compile_commands.json
10+
CTestTestfile.cmake
11+
_deps
12+
build
13+
lib
14+
bin

test/gtest/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(gtest)
3+
4+
# GoogleTest requires at least C++14
5+
set(CMAKE_CXX_STANDARD 14)
6+
7+
include(FetchContent)
8+
FetchContent_Declare(
9+
googletest
10+
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
11+
)
12+
# For Windows: Prevent overriding the parent project's compiler/linker settings
13+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
14+
FetchContent_MakeAvailable(googletest)
15+
16+
enable_testing()
17+
18+
add_executable(
19+
hello_test
20+
hello_test.cc
21+
)
22+
target_link_libraries(
23+
hello_test
24+
GTest::gtest_main
25+
)
26+
27+
include(GoogleTest)
28+
gtest_discover_tests(hello_test)

test/gtest/hello_test.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <gtest/gtest.h>
2+
3+
// Demonstrate some basic assertions.
4+
TEST(HelloTest, BasicAssertions) {
5+
// Expect two strings not to be equal.
6+
EXPECT_STRNE("hello", "world");
7+
// Expect equality.
8+
EXPECT_EQ(7 * 6, 42);
9+
}

0 commit comments

Comments
 (0)