added mock log test
This commit is contained in:
parent
ce3533613b
commit
1398762db8
@ -188,6 +188,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
|
" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
|
||||||
|
|
||||||
|
cmake_push_check_state (RESET)
|
||||||
|
set (CMAKE_REQUIRED_LIBRARIES Threads::Threads)
|
||||||
check_cxx_source_compiles ("
|
check_cxx_source_compiles ("
|
||||||
#define _XOPEN_SOURCE 500
|
#define _XOPEN_SOURCE 500
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -199,6 +201,7 @@ int main(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
" HAVE_RWLOCK)
|
" HAVE_RWLOCK)
|
||||||
|
cmake_pop_check_state ()
|
||||||
|
|
||||||
check_cxx_source_compiles ("
|
check_cxx_source_compiles ("
|
||||||
__declspec(selectany) int a;
|
__declspec(selectany) int a;
|
||||||
@ -830,7 +833,7 @@ if (BUILD_TESTING)
|
|||||||
|
|
||||||
set_tests_properties (logging PROPERTIES TIMEOUT 30)
|
set_tests_properties (logging PROPERTIES TIMEOUT 30)
|
||||||
|
|
||||||
# FIXME: Skip flaky test
|
# FIXME: Skip flaky test
|
||||||
set_tests_properties (logging PROPERTIES SKIP_REGULAR_EXPRESSION
|
set_tests_properties (logging PROPERTIES SKIP_REGULAR_EXPRESSION
|
||||||
"Check failed: time_ns within LogTimes::LOG_PERIOD_TOL_NS of LogTimes::LOG_PERIOD_NS")
|
"Check failed: time_ns within LogTimes::LOG_PERIOD_TOL_NS of LogTimes::LOG_PERIOD_NS")
|
||||||
|
|
||||||
@ -855,6 +858,17 @@ if (BUILD_TESTING)
|
|||||||
add_test (NAME symbolize COMMAND symbolize_unittest)
|
add_test (NAME symbolize COMMAND symbolize_unittest)
|
||||||
endif (TARGET symbolize_unittest)
|
endif (TARGET symbolize_unittest)
|
||||||
|
|
||||||
|
if (HAVE_LIB_GMOCK)
|
||||||
|
add_executable (mock-log_unittest
|
||||||
|
src/mock-log_unittest.cc
|
||||||
|
src/mock-log.h
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries (mock-log_unittest PRIVATE ${_GLOG_TEST_LIBS})
|
||||||
|
|
||||||
|
add_test (NAME mock-log COMMAND mock-log_unittest)
|
||||||
|
endif (HAVE_LIB_GMOCK)
|
||||||
|
|
||||||
# Generate an initial cache
|
# Generate an initial cache
|
||||||
|
|
||||||
get_cache_variables (_CACHEVARS)
|
get_cache_variables (_CACHEVARS)
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
|
|||||||
ScopedMockLog() { AddLogSink(this); }
|
ScopedMockLog() { AddLogSink(this); }
|
||||||
|
|
||||||
// When the object is destructed, it stops intercepting logs.
|
// When the object is destructed, it stops intercepting logs.
|
||||||
virtual ~ScopedMockLog() { RemoveLogSink(this); }
|
~ScopedMockLog() { RemoveLogSink(this); }
|
||||||
|
|
||||||
// Implements the mock method:
|
// Implements the mock method:
|
||||||
//
|
//
|
||||||
|
|||||||
@ -55,7 +55,7 @@ TEST(ScopedMockLogTest, InterceptsLog) {
|
|||||||
ScopedMockLog log;
|
ScopedMockLog log;
|
||||||
|
|
||||||
InSequence s;
|
InSequence s;
|
||||||
EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_test.cc"), "Fishy."));
|
EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_unittest.cc"), "Fishy."));
|
||||||
EXPECT_CALL(log, Log(INFO, _, "Working..."))
|
EXPECT_CALL(log, Log(INFO, _, "Working..."))
|
||||||
.Times(2);
|
.Times(2);
|
||||||
EXPECT_CALL(log, Log(ERROR, _, "Bad!!"));
|
EXPECT_CALL(log, Log(ERROR, _, "Bad!!"));
|
||||||
Loading…
Reference in New Issue
Block a user