diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-09-15 21:15:53 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-09-15 21:15:53 +0200 |
| commit | aa49abdf239bae6065fddd0839ec67a404c9748c (patch) | |
| tree | 631fbb2df58aa35df3d60c65c037ef74b1807114 /test/io.cc | |
| parent | bf41a601fd0447bcf3a2937a595a1cd8ca5c1633 (diff) | |
Add .clang-format
Make it easier to keep a consistent style
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); |
