add gtest demo

master
zcy 2022-03-22 13:43:40 +08:00
parent a24a3f7ad3
commit b3a0fd617b
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.19)
project(gtest_demo)
message("cmake module " $ENV{CMAKE_MODULE_PATH})
message("project dir " ${PROJECT_SOURCE_DIR})
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_CXX_FLAGS "/OPT:NOREF /MTd /std:c++14 /EHsc /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "")
include_directories(E:\\conan_data\\gtest\\1.0\\_\\_\\package\\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\include)
link_directories(E:\\conan_data\\gtest\\1.0\\_\\_\\package\\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\\lib)
link_libraries(gtestd.lib gtest_maind.lib gmockd.lib gmock_maind.lib)
add_executable(gtest_demo gtest_demo.cpp)
set_property(TARGET gtest_demo PROPERTY
MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
target_include_directories(gtest_demo SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc/third/include)

View File

@ -0,0 +1,13 @@
#include<gtest/gtest.h>
int add(int a,int b){
return a+b;
}
TEST(testCase,test0){
EXPECT_EQ(add(2,3),5);
}
int main(int argc,char **argv){
testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}