diff --git a/test/test_utility.cpp b/test/test_utility.cpp index d2c3dae..6f4d47c 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -1,6 +1,7 @@ #include // std::aligned_storage_t #include +#include #include "gtest/gtest.h" @@ -86,3 +87,14 @@ TEST(utility, pimpl_inherit) { EXPECT_EQ(ipc::pimpl::get(pbar)->pj_, &j); pbar->clear(); } + +TEST(utility, countof) { + struct { + constexpr int Size() const noexcept { return 3; } + } sv; + std::vector vec {1, 2, 3, 4, 5}; + int arr[] {7, 6, 5, 4, 3, 2, 1}; + EXPECT_EQ(ipc::countof(sv) , sv.Size()); + EXPECT_EQ(ipc::countof(vec), vec.size()); + EXPECT_EQ(ipc::countof(arr), sizeof(arr) / sizeof(arr[0])); +}