blob: bf7355698fd8c561a06d0e7462e4a81161449956 [file] [log] [blame]
#include <stdplus/fd/create.hpp>
#include <stdplus/fd/mmap.hpp>
#include <array>
#include <gtest/gtest.h>
namespace stdplus
{
namespace fd
{
TEST(MMap, Basic)
{
auto fd = open("/dev/zero", OpenAccess::ReadOnly);
auto map = MMap(fd, 32, ProtFlags().set(ProtFlag::Read),
MMapFlags{MMapAccess::Private}, 0);
auto sp = map.get();
ASSERT_NE(nullptr, sp.data());
ASSERT_EQ(32, sp.size());
for (size_t i = 0; i < 32; ++i)
{
EXPECT_EQ(sp[i], std::byte{});
}
}
} // namespace fd
} // namespace stdplus