Skip to content

Commit 262d33f

Browse files
committedJul 29, 2024
timerlat_pipe_load: check stderr with gmock matcher
1 parent 7a32332 commit 262d33f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎timerlat_pipe_load.hh

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public:
6161
// Note that any open file is automatically closed when the fstream object is
6262
// destroyed.
6363
~FifoTimer() {
64-
std::cerr << "Destructor" << std::endl;
6564
if (responder_.joinable()) {
6665
stop();
6766
}

‎timerlat_pipe_load_lib_test.cc

+6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <exception>
88
#include <stdexcept>
99

10+
#include "gmock/gmock-matchers.h"
1011
#include "gtest/gtest.h"
12+
#include "gtest/internal/gtest-port.h"
1113

1214
using namespace std;
1315
using namespace std::chrono;
@@ -77,7 +79,11 @@ TEST(TimerlatPipeLoadTest, BadMinimalResponder) {
7779
// std::cerr << "Oops, an exception." << std::endl;
7880
// }
7981
std::function<void(const std::string &)> empty_fn;
82+
::testing::internal::CaptureStderr();
8083
EXPECT_FALSE(ft.create_responder(empty_fn));
84+
const std::string output = ::testing::internal::GetCapturedStderr();
85+
EXPECT_THAT(output, ::testing::HasSubstr(
86+
"Supplied thread function is not executable."));
8187
}
8288

8389
TEST(TimerlatPipeLoadTest, Start) {

0 commit comments

Comments
 (0)
Please sign in to comment.