From caf2b45cc460faced8ff264259e4cd05cb571e8a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 21 Sep 2023 22:15:42 -0400 Subject: Use anonymous namespaces instead of "static" in tests --- test/maid_test.cpp | 16 ++++++++++------ test/sem_test.cpp | 8 ++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/test/maid_test.cpp b/test/maid_test.cpp index 286be2a..0456913 100644 --- a/test/maid_test.cpp +++ b/test/maid_test.cpp @@ -15,11 +15,13 @@ using raul::Maid; -static const size_t n_threads = 8U; -static const size_t n_junk_per_thread = 1U << 16U; +namespace { -static std::atomic n_junk(0); -static std::atomic n_finished_threads(0); +const size_t n_threads = 8U; +const size_t n_junk_per_thread = 1U << 16U; + +std::atomic n_junk(0); +std::atomic n_finished_threads(0); class Junk : public Maid::Disposable { @@ -43,7 +45,7 @@ private: size_t _val; }; -static void +void litter(Maid* maid) { for (size_t i = 0; i < n_junk_per_thread; ++i) { @@ -54,7 +56,7 @@ litter(Maid* maid) ++n_finished_threads; } -static void +void test() { Maid maid; @@ -120,6 +122,8 @@ test() assert(n_junk == 1); } +} // namespace + int main() { diff --git a/test/sem_test.cpp b/test/sem_test.cpp index ae82c91..103e5e5 100644 --- a/test/sem_test.cpp +++ b/test/sem_test.cpp @@ -9,19 +9,23 @@ #include #include -static void +namespace { + +void wait_for_sem(raul::Semaphore* sem) { sem->wait(); } -static void +void timed_wait_for_sem(raul::Semaphore* sem) { while (!sem->timed_wait(std::chrono::milliseconds(100))) { } } +} // namespace + int main() { -- cgit v1.2.1