From 851d4fb9db087eeb183f1c1cb5d96829a32e690b Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Tue, 8 Aug 2023 22:18:28 +0200 Subject: add clang-tidy and fix lints --- test/option.cc | 26 +++++++++++++------------- test/timer.cc | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/test/option.cc b/test/option.cc index 0417266..30b2406 100644 --- a/test/option.cc +++ b/test/option.cc @@ -2,31 +2,31 @@ #include #include -struct Checker { +struct checker { static unsigned cnt; - Checker() { + checker() { ++cnt; } - Checker(const Checker&) { + checker(const checker&) { ++cnt; } - Checker(Checker&&) { + checker(checker&&) noexcept { ++cnt; } - ~Checker() { + ~checker() { --cnt; } }; -unsigned Checker::cnt = 0; +unsigned checker::cnt = 0; int main() { using option::option; auto check_cnt = [](unsigned expect) { - if (expect != Checker::cnt) { - std::printf("Checker: expect=%u cnt=%u\n", expect, Checker::cnt); + if (expect != checker::cnt) { + std::printf("Checker: expect=%u cnt=%u\n", expect, checker::cnt); std::abort(); } }; @@ -43,18 +43,18 @@ int main() { check_cnt(0); { - option o1(Checker{}); + option o1(checker{}); // copy construct - option o2 = o1; + option o2 = o1; // move construct - option o3 = o1.take(); + option o3 = o1.take(); assert(!o1.has_value()); assert(o2.has_value()); assert(o3.has_value()); // move option - option o4 = std::move(o2); + option o4 = std::move(o2); assert(!o2.has_value()); assert(o4.has_value()); @@ -74,7 +74,7 @@ int main() { check_cnt(0); { - option o1; + option o1; assert(!o1.has_value()); o1.emplace(); diff --git a/test/timer.cc b/test/timer.cc index 078c4bb..6bc783c 100644 --- a/test/timer.cc +++ b/test/timer.cc @@ -3,26 +3,26 @@ #include int main() { - timer::timer T; + timer::timer t; - const auto show_time = [&T]() { - std::fprintf(stderr, "usec=%f msec=%f sec=%f\n", T.as_usec(), T.as_msec(), - T.as_sec()); + const auto kShowTime = [&t]() { + std::fprintf(stderr, "usec=%f msec=%f sec=%f\n", t.as_usec(), t.as_msec(), + t.as_sec()); }; { puts("Sleep 100ms"); - timer::scoped_timer s{T}; + timer::scoped_timer s{t}; usleep(100 * 1000); } - show_time(); + kShowTime(); { puts("Sleep 500ms"); - timer::scoped_timer s{T}; + timer::scoped_timer s{t}; usleep(500 * 1000); } - show_time(); + kShowTime(); return 0; } -- cgit v1.2.3