#include <gtest/gtest.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <string>
EXPECT_EQ(expected, s);
}
+TEST(io, WriteFdExactly_ENOSPC) {
+ int fd = open("/dev/full", O_WRONLY);
+ ASSERT_NE(-1, fd);
+
+ char buf[] = "foo";
+ ASSERT_FALSE(WriteFdExactly(fd, buf, sizeof(buf)));
+ ASSERT_EQ(ENOSPC, errno);
+}
+
TEST(io, WriteStringFully) {
const char str[] = "Foobar";
TemporaryFile tf;