Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 1398762

Browse files
committed
added mock log test
1 parent ce35336 commit 1398762

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ int main(void)
188188
}
189189
" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
190190

191+
cmake_push_check_state (RESET)
192+
set (CMAKE_REQUIRED_LIBRARIES Threads::Threads)
191193
check_cxx_source_compiles ("
192194
#define _XOPEN_SOURCE 500
193195
#include <pthread.h>
@@ -199,6 +201,7 @@ int main(void)
199201
return 0;
200202
}
201203
" HAVE_RWLOCK)
204+
cmake_pop_check_state ()
202205

203206
check_cxx_source_compiles ("
204207
__declspec(selectany) int a;
@@ -830,7 +833,7 @@ if (BUILD_TESTING)
830833
831834
set_tests_properties (logging PROPERTIES TIMEOUT 30)
832835
833-
# FIXME: Skip flaky test
836+
# FIXME: Skip flaky test
834837
set_tests_properties (logging PROPERTIES SKIP_REGULAR_EXPRESSION
835838
"Check failed: time_ns within LogTimes::LOG_PERIOD_TOL_NS of LogTimes::LOG_PERIOD_NS")
836839
@@ -855,6 +858,17 @@ if (BUILD_TESTING)
855858
add_test (NAME symbolize COMMAND symbolize_unittest)
856859
endif (TARGET symbolize_unittest)
857860
861+
if (HAVE_LIB_GMOCK)
862+
add_executable (mock-log_unittest
863+
src/mock-log_unittest.cc
864+
src/mock-log.h
865+
)
866+
867+
target_link_libraries (mock-log_unittest PRIVATE ${_GLOG_TEST_LIBS})
868+
869+
add_test (NAME mock-log COMMAND mock-log_unittest)
870+
endif (HAVE_LIB_GMOCK)
871+
858872
# Generate an initial cache
859873
860874
get_cache_variables (_CACHEVARS)

src/mock-log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
7272
ScopedMockLog() { AddLogSink(this); }
7373

7474
// When the object is destructed, it stops intercepting logs.
75-
virtual ~ScopedMockLog() { RemoveLogSink(this); }
75+
~ScopedMockLog() { RemoveLogSink(this); }
7676

7777
// Implements the mock method:
7878
//
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ TEST(ScopedMockLogTest, InterceptsLog) {
5555
ScopedMockLog log;
5656

5757
InSequence s;
58-
EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_test.cc"), "Fishy."));
58+
EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_unittest.cc"), "Fishy."));
5959
EXPECT_CALL(log, Log(INFO, _, "Working..."))
6060
.Times(2);
6161
EXPECT_CALL(log, Log(ERROR, _, "Bad!!"));

0 commit comments

Comments
 (0)