mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
添加countof ut
This commit is contained in:
parent
1ff5900a6d
commit
daa3c30f4c
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include <type_traits> // std::aligned_storage_t
|
#include <type_traits> // std::aligned_storage_t
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
@ -86,3 +87,14 @@ TEST(utility, pimpl_inherit) {
|
|||||||
EXPECT_EQ(ipc::pimpl::get(pbar)->pj_, &j);
|
EXPECT_EQ(ipc::pimpl::get(pbar)->pj_, &j);
|
||||||
pbar->clear();
|
pbar->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(utility, countof) {
|
||||||
|
struct {
|
||||||
|
constexpr int Size() const noexcept { return 3; }
|
||||||
|
} sv;
|
||||||
|
std::vector<int> 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]));
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user