aboutsummaryrefslogtreecommitdiff
path: root/test/common/platform/unix
diff options
context:
space:
mode:
Diffstat (limited to 'test/common/platform/unix')
-rw-r--r--test/common/platform/unix/UnixFileStreamTest.cpp30
-rw-r--r--test/common/platform/unix/UnixFileTest.cpp38
2 files changed, 0 insertions, 68 deletions
diff --git a/test/common/platform/unix/UnixFileStreamTest.cpp b/test/common/platform/unix/UnixFileStreamTest.cpp
deleted file mode 100644
index 417fccc2..00000000
--- a/test/common/platform/unix/UnixFileStreamTest.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "cru/base/platform/unix/UnixFileStream.h"
-
-#include <catch2/catch_test_macros.hpp>
-
-#include <fcntl.h>
-#include <filesystem>
-
-TEST_CASE("UnixFileStream Work", "[stream]") {
- using namespace cru;
- using namespace cru::io;
- using namespace cru::platform::unix;
-
- auto temp_file_path =
- (std::filesystem::temp_directory_path() / "cru_test_temp.XXXXXX")
- .generic_string();
- mkstemp(temp_file_path.data());
-
- UnixFileStream file(temp_file_path.c_str(), O_WRONLY | O_CREAT);
- file.Write("abc", 3);
- file.Close();
-
- UnixFileStream file2(temp_file_path.c_str(), O_RDONLY);
- auto buffer = std::make_unique<std::byte[]>(3);
- file2.Read(buffer.get(), 3);
- REQUIRE(std::string_view(reinterpret_cast<const char*>(buffer.get()), 3) ==
- "abc");
- file2.Close();
-
- std::filesystem::remove(temp_file_path);
-}
diff --git a/test/common/platform/unix/UnixFileTest.cpp b/test/common/platform/unix/UnixFileTest.cpp
deleted file mode 100644
index d5bba0db..00000000
--- a/test/common/platform/unix/UnixFileTest.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-#include "cru/base/platform/unix/UnixFileStream.h"
-
-#include <catch2/catch_test_macros.hpp>
-
-#include <fcntl.h>
-#include <filesystem>
-
-TEST_CASE("UnixFile Work", "[unix]") {
- using namespace cru;
- using namespace cru::platform::unix;
-
- auto calledTimes = 0;
- auto mockClose = [&calledTimes](int _) {
- calledTimes += 1;
- return 0;
- };
-
- auto temp_file_path =
- (std::filesystem::temp_directory_path() / "cru_test_temp.XXXXXX")
- .generic_string();
- mkstemp(temp_file_path.data());
-
- auto fdNumber = ::open(temp_file_path.c_str(), O_WRONLY | O_CREAT);
-
- {
- UnixFileDescriptor fd(fdNumber, true, std::move(mockClose));
- REQUIRE(calledTimes == 0);
- UnixFileDescriptor fd2(std::move(fd));
- REQUIRE(calledTimes == 0);
- UnixFileDescriptor fd3;
- fd3 = std::move(fd2);
- REQUIRE(calledTimes == 0);
- }
- REQUIRE(calledTimes == 1);
-
- std::filesystem::remove(temp_file_path);
-}