Skip to content

Commit

Permalink
fix: clang-tidy issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
  • Loading branch information
xDimon committed Oct 14, 2024
1 parent f972058 commit c288f33
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions example/01-simple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int main() {

auto r = log_system.configure();
if (not r.message.empty()) {
(r.has_error ? std::cerr : std::cout) << r.message << std::endl;
(r.has_error ? std::cerr : std::cout) << r.message << '\n';
}
if (r.has_error) {
exit(EXIT_FAILURE);
Expand All @@ -125,7 +125,7 @@ int main() {
main_log->info("Start");

auto lambda = [](const auto &tag) {
std::cout << "CALCULATED: " << tag << std::endl;
std::cout << "CALCULATED: " << tag << '\n';
return tag;
};

Expand Down
7 changes: 4 additions & 3 deletions src/impl/sink_to_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace soralog {
out_.open(path_, std::ios::app);
if (not out_.is_open()) {
std::cerr << "Can't open log file '" << path_ << "': " << strerror(errno)
<< std::endl;
<< '\n';
} else if (latency_ != std::chrono::milliseconds::zero()) {
sink_worker_ = std::make_unique<std::thread>([this] { run(); });
}
Expand Down Expand Up @@ -229,11 +229,12 @@ namespace soralog {
if (not out.is_open()) {
if (out_.is_open()) {
std::cerr << "Can't re-open log file '" << path_
<< "': " << strerror(errno) << std::endl;
<< "': " << strerror(errno) << '\n';
} else {
std::cerr << "Can't open log file '" << path_
<< "': " << strerror(errno) << std::endl;
<< "': " << strerror(errno) << '\n';
}
std::cerr.flush();
} else {
std::swap(out_, out);
}
Expand Down
28 changes: 14 additions & 14 deletions test/unit/circular_buffer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TEST_F(CircularBufferTest, Put) {
EXPECT_EQ(testee.avail(), capacity - i);
EXPECT_EQ(testee.capacity(), capacity);

std::cout << "--- put #" << (i + 1) << std::endl;
std::cout << "--- put #" << (i + 1) << '\n';
auto ref = testee.put('1' + i);
EXPECT_TRUE(ref);
}
Expand All @@ -65,14 +65,14 @@ TEST_F(CircularBufferTest, Put) {
EXPECT_EQ(testee.capacity(), capacity);

// Overfill
std::cout << "--- put #" << (capacity + 1) << " (overfill)" << std::endl;
std::cout << "--- put #" << (capacity + 1) << " (overfill)" << '\n';
auto ref = testee.put('1' + capacity);
EXPECT_FALSE(ref);

EXPECT_EQ(testee.size(), capacity);
EXPECT_EQ(testee.avail(), 0);
EXPECT_EQ(testee.capacity(), capacity);
std::cout << '\n' << std::endl;
std::cout << '\n' << '\n';
}

TEST_F(CircularBufferTest, Get) {
Expand All @@ -85,7 +85,7 @@ TEST_F(CircularBufferTest, Get) {
EXPECT_EQ(testee.avail(), capacity);
EXPECT_EQ(testee.capacity(), capacity);

std::cout << "--- get (nothing actually)" << std::endl;
std::cout << "--- get (nothing actually)" << '\n';
auto ref = testee.get();
EXPECT_FALSE(ref);
}
Expand All @@ -101,7 +101,7 @@ TEST_F(CircularBufferTest, Get) {
EXPECT_EQ(testee.avail(), i);
EXPECT_EQ(testee.capacity(), capacity);

std::cout << "--- get #" << (i + 1) << std::endl;
std::cout << "--- get #" << (i + 1) << '\n';
auto ref = testee.get();
EXPECT_TRUE(ref);

Expand All @@ -127,7 +127,7 @@ TEST_F(CircularBufferTest, PutGet) {
std::cout << "[lag=" << lag << "]: " //
<< "put " << ref_put->c() << " > " //
<< "size=" << testee.size() << " avail=" << testee.avail()
<< std::endl;
<< '\n';
}
for (auto n = 0; n < capacity; ++n) {
{
Expand All @@ -137,15 +137,15 @@ TEST_F(CircularBufferTest, PutGet) {
std::cout << "[lag=" << lag << "]: " //
<< "put " << ref_put->c() << " > " //
<< "size=" << testee.size() << " avail=" << testee.avail()
<< std::endl;
<< '\n';
}
{
auto ref_get = testee.get();
EXPECT_TRUE(ref_get);
std::cout << "[lag=" << lag << "]: " //
<< "get " << ref_get->c() << " > " //
<< "size=" << testee.size() << " avail=" << testee.avail()
<< std::endl;
<< '\n';
}
}
}
Expand All @@ -168,13 +168,13 @@ TEST_F(CircularBufferTest, PutGetMt) {
latch.arrive_and_wait();
#endif
while (i < n) {
std::cout << "w" << i << std::endl;
std::cout << "w" << i << '\n';
// if (auto ref = testee.put('0' + (i % 10))) {
if (auto ref = testee.put('0')) {
++i;
std::cout << "put " << ref->c() //
<< " [" << testee.size() << " | " << testee.avail() << "]"
<< std::endl;
<< '\n';
}
std::this_thread::sleep_for(std::chrono::milliseconds(3 + random() % 50));
}
Expand All @@ -185,11 +185,11 @@ TEST_F(CircularBufferTest, PutGetMt) {
latch.arrive_and_wait();
#endif
while (i < n) {
std::cout << "r" << std::endl;
std::cout << "r" << '\n';
if (auto ref = testee.get()) {
std::cout << "get " << ref->c() //
<< " [" << testee.size() << " | " << testee.avail() << "]"
<< std::endl;
<< '\n';
}
std::this_thread::sleep_for(std::chrono::milliseconds(3 + random() % 50));
}
Expand Down Expand Up @@ -218,7 +218,7 @@ TEST_F(CircularBufferTest, Mutual) {
if (auto ref = testee.put('*')) {
std::cout << "put " << ref->c() //
<< " [" << testee.size() << " | " << testee.avail() << "]"
<< std::endl;
<< '\n';
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
});
Expand All @@ -231,7 +231,7 @@ TEST_F(CircularBufferTest, Mutual) {
if (auto ref = testee.get()) {
std::cout << "get " << ref->c() //
<< " [" << testee.size() << " | " << testee.avail() << "]"
<< std::endl;
<< '\n';
}
});

Expand Down

0 comments on commit c288f33

Please sign in to comment.