From ee6e09aceac2b73184f48a6b60a8540be1b59f53 Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Wed, 1 Apr 2020 00:22:51 +0800 Subject: [PATCH] gtest ui --- .vscode/settings.json | 28 +++++++++++++++++++++++++++- .vscode/tasks.json | 4 ++-- CMakeLists.txt | 5 ++++- gtest/CMakeLists.txt | 8 ++++++-- gtest/vbt_test.cpp | 9 +++++++++ 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 4fd5570..4b68f85 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,29 @@ { - "C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools" + "C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools", + "editor.tokenColorCustomizations": { + "textMateRules": [ + { + "scope": "googletest.failed", + "settings": { + "foreground": "#f00" + } + }, + { + "scope": "googletest.passed", + "settings": { + "foreground": "#0f0" + } + }, + { + "scope": "googletest.run", + "settings": { + "foreground": "#0f0" + } + } + ] + }, + "gtest-adapter.debugConfig": [ + "(gdb) gtest bug" + ], + "gtest-adapter.supportLocation": true } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 76b1f55..f21deaf 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -9,7 +9,7 @@ "command": "/usr/bin/bash", "args": [ "-c", - "cd ${workspaceFolder}/build && cmake .. && make -j4", + "cd ${workspaceFolder}/build && cmake .. -DCMAKE_BUILD_TYPE=Debug && make -j4", ], "options": { "cwd": "/bin" @@ -25,7 +25,7 @@ "command": "/usr/bin/bash", "args": [ "-c", - "cd ${workspaceFolder}/gtest && mkdir -p build && cd build && cmake .. && make -j4", + "cd ${workspaceFolder}/gtest && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug && make -j4", ], "options": { "cwd": "/bin" diff --git a/CMakeLists.txt b/CMakeLists.txt index 999a668..d70ecda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ cmake_minimum_required(VERSION 3.5.0) project(orderly VERSION 0.1.0) +SET(CMAKE_BUILD_TYPE "Debug") +SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb") +SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall") + include(CTest) enable_testing() -include(GoogleTest) include_directories( ${CMAKE_CURRENT_LIST_DIR}/src /usr/include diff --git a/gtest/CMakeLists.txt b/gtest/CMakeLists.txt index 70044e2..e87a9e3 100644 --- a/gtest/CMakeLists.txt +++ b/gtest/CMakeLists.txt @@ -1,10 +1,14 @@ +enable_testing() + +find_package(GTest REQUIRED) +find_package(Threads REQUIRED) include_directories( ${CMAKE_CURRENT_LIST_DIR}/../src ) -include(GoogleTest) +# include(GoogleTest) add_executable(vbt_test vbt_test.cpp) target_link_libraries( @@ -14,4 +18,4 @@ target_link_libraries( pthread ) -add_test(vbt_test vbt_test) \ No newline at end of file +add_test(NAME vbt_test COMMAND vbt_test) \ No newline at end of file diff --git a/gtest/vbt_test.cpp b/gtest/vbt_test.cpp index 6186869..2aeef89 100644 --- a/gtest/vbt_test.cpp +++ b/gtest/vbt_test.cpp @@ -6,4 +6,13 @@ TEST(vbt_test, put) { VBTree vbt; vbt.put(0, 0); +} + +TEST(vbt_test, get) { + VBTree vbt; + vbt.put(0, 0); + vbt.put(1, 1); + int * result; + result = vbt.get(1); + ASSERT_TRUE(*result == 1); } \ No newline at end of file