summaryrefslogtreecommitdiff
path: root/test/io.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-09-15 21:15:53 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-09-15 21:15:53 +0200
commitaa49abdf239bae6065fddd0839ec67a404c9748c (patch)
tree631fbb2df58aa35df3d60c65c037ef74b1807114 /test/io.cc
parentbf41a601fd0447bcf3a2937a595a1cd8ca5c1633 (diff)
Add .clang-format
Make it easier to keep a consistent style
Diffstat (limited to 'test/io.cc')
-rw-r--r--test/io.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/test/io.cc b/test/io.cc
index d6e5161..843c83e 100644
--- a/test/io.cc
+++ b/test/io.cc
@@ -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);