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