new gtest
This commit is contained in:
@@ -1,28 +1,34 @@
|
||||
include(DownloadGTest)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/suppr.txt ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
macro(pip_test NAME LIBS)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/58d77fa8070e8cec2dc1ed015d66b454c8d78850.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
enable_testing()
|
||||
|
||||
include(GoogleTest)
|
||||
|
||||
macro(pip_test NAME)
|
||||
file(GLOB _CPPS "${NAME}/*.cpp")
|
||||
file(GLOB _HDRS "${NAME}/*.h")
|
||||
set(_target pip_${NAME}_test)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PIP_ROOT_BINARY_DIR}")
|
||||
add_executable(${_target} ${_CPPS} ${_HDRS})
|
||||
if (NOT WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${_target} PRIVATE -fsanitize=address,undefined)
|
||||
target_link_options(${_target} PRIVATE -fsanitize=address,undefined)
|
||||
target_link_libraries(${_target} asan)
|
||||
endif()
|
||||
target_link_libraries(${_target} pip ${LIBS} gtest_main gmock_main)
|
||||
add_test(NAME ${_target} COMMAND tests)
|
||||
add_custom_target(${_target}_perform ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E env "LSAN_OPTIONS=suppressions=suppr.txt" $<TARGET_FILE:${_target}>)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
target_link_libraries(${_target} pip ${ARGN} gtest_main)
|
||||
gtest_discover_tests(${_target})
|
||||
list(APPEND PIP_TESTS_LIST "${NAME}")
|
||||
set(PIP_TESTS_LIST ${PIP_TESTS_LIST} PARENT_SCOPE)
|
||||
endmacro()
|
||||
|
||||
pip_test(concurrent "")
|
||||
pip_test(math "")
|
||||
pip_test(core "")
|
||||
pip_test(piobject "")
|
||||
#pip_test(concurrent)
|
||||
pip_test(math)
|
||||
pip_test(core)
|
||||
pip_test(piobject)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.8.2)
|
||||
|
||||
project(googletest-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG "dea0216d0c6bc5e63cf5f6c8651cd268668032ec"
|
||||
GIT_CONFIG "advice.detachedHead=false"
|
||||
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
|
||||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
@@ -1,17 +1,9 @@
|
||||
#include "pistring.h"
|
||||
|
||||
#include "math.h"
|
||||
#include "pistringlist.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
template<typename T>
|
||||
bool is_equal(T x, T y) {
|
||||
return std::fabs(x - y) < std::numeric_limits<T>::epsilon();
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, constructor_empty) {
|
||||
PIString str1;
|
||||
ASSERT_TRUE(str1.isEmpty());
|
||||
@@ -498,107 +490,3 @@ TEST(PIString_Tests, operator_grater_eq_cstring_true_equal) {
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_pistring) {
|
||||
PIString str1 = "shift";
|
||||
PIString str2 = " good";
|
||||
str1 << str2;
|
||||
PIString res = "shift good";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_pichar) {
|
||||
PIString str1 = "shif";
|
||||
PIChar str2 = 't';
|
||||
str1 << str2;
|
||||
PIString res = "shift";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_cstring) {
|
||||
PIString str1 = "shif";
|
||||
char str2[] = "t chat";
|
||||
str1 << str2;
|
||||
PIString res = "shift chat";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_wchar_t) {
|
||||
PIString str1 = "shif";
|
||||
wchar_t str2[] = L"t cc";
|
||||
str1 << str2;
|
||||
PIString res = "shift cc";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_int) {
|
||||
PIString str1 = "shift ";
|
||||
int numb = -2147483648;
|
||||
str1 << numb;
|
||||
PIString res = "shift -2147483648";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_uint) {
|
||||
PIString str1 = "shift ";
|
||||
uint numb = 4294967295;
|
||||
str1 << numb;
|
||||
PIString res = "shift 4294967295";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_short) {
|
||||
PIString str1 = "shift ";
|
||||
short numb = -32768;
|
||||
str1 << numb;
|
||||
PIString res = "shift -32768";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ushort) {
|
||||
PIString str1 = "shift ";
|
||||
ushort numb = 65535;
|
||||
str1 << numb;
|
||||
PIString res = "shift 65535";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_long) {
|
||||
PIString str1 = "shift ";
|
||||
long numb = -2147483648;
|
||||
str1 << numb;
|
||||
PIString res = "shift -2147483648";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ulong) {
|
||||
PIString str1 = "shift ";
|
||||
ulong numb = 4294967295;
|
||||
str1 << numb;
|
||||
PIString res = "shift 4294967295";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_llong) {
|
||||
PIString str1 = "shift ";
|
||||
llong numb = -9223372036854775807;
|
||||
str1 << numb;
|
||||
PIString res = "shift -9223372036854775807";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ullong) {
|
||||
PIString str1 = "shift ";
|
||||
ullong numb = 1844674407370955161;
|
||||
str1 << numb;
|
||||
PIString res = "shift 1844674407370955161";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_float) {
|
||||
PIString str1 = "shift ";
|
||||
float numb = -67.88999939f;
|
||||
str1 << numb;
|
||||
PIString res = "shift -67.88999939";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "piobject.h"
|
||||
#include "pitime.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
leak:ConditionVariable::SetUp
|
||||
leak:ConditionLock_
|
||||
Reference in New Issue
Block a user