blob: bf7355698fd8c561a06d0e7462e4a81161449956 [file] [log] [blame]
William A. Kennington III891e6a32022-05-17 16:35:03 -07001#include <stdplus/fd/create.hpp>
2#include <stdplus/fd/mmap.hpp>
3
Patrick Williamsd1984dd2023-05-10 16:12:44 -05004#include <array>
5
6#include <gtest/gtest.h>
7
William A. Kennington III891e6a32022-05-17 16:35:03 -07008namespace stdplus
9{
10namespace fd
11{
12
13TEST(MMap, Basic)
14{
15 auto fd = open("/dev/zero", OpenAccess::ReadOnly);
16 auto map = MMap(fd, 32, ProtFlags().set(ProtFlag::Read),
17 MMapFlags{MMapAccess::Private}, 0);
18 auto sp = map.get();
19 ASSERT_NE(nullptr, sp.data());
20 ASSERT_EQ(32, sp.size());
21 for (size_t i = 0; i < 32; ++i)
22 {
23 EXPECT_EQ(sp[i], std::byte{});
24 }
25}
26
27} // namespace fd
28} // namespace stdplus