diff options
Diffstat (limited to 'tests/test-process.cpp')
-rw-r--r-- | tests/test-process.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test-process.cpp b/tests/test-process.cpp index dfee83f..9855546 100644 --- a/tests/test-process.cpp +++ b/tests/test-process.cpp @@ -1,5 +1,7 @@ #include <gtest/gtest.h> +#include <thread> + #include "process.h" #include <unistd.h> @@ -23,7 +25,7 @@ protected: }; -TEST_F(ProcessTest,is_running) { +TEST_F(ProcessTest, is_running) { auto pid{::getpid()}; EXPECT_NE(pid, -1); @@ -32,3 +34,11 @@ TEST_F(ProcessTest,is_running) { EXPECT_EQ(Reichwein::Process::is_running(999999999), false); } + +TEST_F(ProcessTest, number_of_threads) { + EXPECT_EQ(Reichwein::Process::number_of_threads(::getpid()), 1); + std::thread t1{[](){std::this_thread::sleep_for(std::chrono::milliseconds(50));}}; + EXPECT_EQ(Reichwein::Process::number_of_threads(::getpid()), 2); + t1.join(); + EXPECT_EQ(Reichwein::Process::number_of_threads(::getpid()), 1); +} |