diff options
Diffstat (limited to 'test/io.cc')
| -rw-r--r-- | test/io.cc | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -1,12 +1,12 @@ -#include <gtest/gtest.h> - #include "io.hh" + #include "io_test_helper.hh" #include <cerrno> #include <cstdlib> #include <dirent.h> #include <fcntl.h> +#include <gtest/gtest.h> #include <sys/stat.h> #include <unistd.h> #include <utility> @@ -15,11 +15,14 @@ namespace { bool remove_recursive(int fd) { auto* dir = fdopendir(fd); - if (!dir) return false; + if (!dir) + return false; while (auto* ent = readdir(dir)) { if (ent->d_name[0] == '.') { - if (ent->d_name[1] == '\0') continue; - if (ent->d_name[1] == '.' && ent->d_name[2] == '\0') continue; + if (ent->d_name[1] == '\0') + continue; + if (ent->d_name[1] == '.' && ent->d_name[2] == '\0') + continue; } bool is_dir; if (ent->d_type == DT_DIR) { @@ -86,14 +89,13 @@ class IoTest : public testing::Test { rmdir(tmpdir_.c_str()); } - [[nodiscard]] int dirfd() const { - return dirfd_; - } + [[nodiscard]] int dirfd() const { return dirfd_; } void touch(const std::string& name, const std::string& value = "") { auto fd = openat(dirfd(), name.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0700); EXPECT_NE(-1, fd); - if (fd == -1) return; + if (fd == -1) + return; size_t offset = 0; while (offset < value.size()) { auto ret = write(fd, value.data() + offset, value.size() - offset); |
