File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ out /
2+ .vscode /settings.json
3+ * .disabled
4+
Original file line number Diff line number Diff line change 1+ {
2+ // Use IntelliSense to learn about possible attributes.
3+ // Hover to view descriptions of existing attributes.
4+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+ "version" : " 0.2.0" ,
6+ "configurations" : [
7+ {
8+ "name" : " C++ Unit Tests" ,
9+ "type" : " cppdbg" ,
10+ "request" : " launch" ,
11+ "program" : " ${workspaceFolder}/out/unit_tests" ,
12+ "args" : [" arg1" , " arg2" ],
13+ "environment" : [{ "name" : " config" , "value" : " Debug" }],
14+ "cwd" : " ${workspaceFolder}"
15+ }
16+
17+ ]
18+ }
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 2.0.0" ,
3+ "tasks" : [
4+ {
5+ "label" : " Build C++ Tests" ,
6+ "type" : " shell" ,
7+ "command" : " cmake" ,
8+ "args" : [
9+ " --build" ,
10+ " ${workspaceFolder}/out/"
11+ ],
12+ "group" : {
13+ "kind" : " build" ,
14+ "isDefault" : true
15+ },
16+ "problemMatcher" : [" $gcc" ],
17+ "detail" : " Build all C++ unit tests"
18+ },
19+ {
20+ "label" : " Run C++ Tests" ,
21+ "type" : " shell" ,
22+ "command" : " ${workspaceFolder}/out/unit_tests" ,
23+ "group" : {
24+ "kind" : " test" ,
25+ "isDefault" : false
26+ },
27+ "problemMatcher" : [],
28+ "detail" : " Execute all C++ unit tests"
29+
30+ }
31+ ]
32+ }
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.12 )
2+
3+ project (example)
4+
5+ set (CMAKE_CXX_STANDARD 23)
6+ add_compile_options (-g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wfloat-conversion )
7+
8+ # Locate GTest
9+ find_package (GTest REQUIRED )
10+ include_directories (${GTEST_INCLUDE_DIRS} )
11+
12+ # Link unit_tests with what we want to test and the GTest and pthread library
13+ add_executable (unit_tests ${SOURCES}
14+ test /unit_testing_main.cpp
15+ )
16+ target_link_libraries (unit_tests ${GTEST_LIBRARIES} pthread )
17+
Original file line number Diff line number Diff line change 1+ # ______
2+
3+ ## Getting started
4+
5+ 1 . Install dependencies
6+ ``` bash
7+ sudo apt install g++ cmake libgtest-dev
8+ ```
9+
10+ 2 . Clone the repo
11+ ``` bash
12+ git clone # ...
13+ cd # ... navigate into the freshly cloned repo
14+ ```
15+
16+ 3 . Build and run:
17+ ``` bash
18+ mkdir out && cd out && cmake .. && cd .. # out-of-source build
19+ cmake --build out/ && ./out/unit_tests
20+ ```
21+
Original file line number Diff line number Diff line change 1+ #include < gtest/gtest.h>
2+
3+ TEST (Testsuite, True)
4+ {
5+ ASSERT_TRUE (true );
6+ }
7+
8+ int main (int argc, char **argv)
9+ {
10+ testing::InitGoogleTest (&argc, argv);
11+ return RUN_ALL_TESTS ();
12+ }
You can’t perform that action at this time.
0 commit comments