William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame] | 1 | #include <stdplus/fd/create.hpp> |
| 2 | #include <stdplus/fd/mmap.hpp> |
| 3 | |
Patrick Williams | d1984dd | 2023-05-10 16:12:44 -0500 | [diff] [blame] | 4 | #include <array> |
| 5 | |
| 6 | #include <gtest/gtest.h> |
| 7 | |
William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame] | 8 | namespace stdplus |
| 9 | { |
| 10 | namespace fd |
| 11 | { |
| 12 | |
| 13 | TEST(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 |