diff options
author | crupest <crupest@outlook.com> | 2022-02-03 17:55:00 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-03 17:55:00 +0800 |
commit | 5aca7b099c46a87a859f40110efce708200a4bc8 (patch) | |
tree | 76a0daef247ab2b2269eebdbbda10134f213d1ca /test/common/io/UnixFileStreamTest.cpp | |
parent | d15172cfe1ac8558567c1b1c10c2e671b0d1f033 (diff) | |
download | cru-5aca7b099c46a87a859f40110efce708200a4bc8.tar.gz cru-5aca7b099c46a87a859f40110efce708200a4bc8.tar.bz2 cru-5aca7b099c46a87a859f40110efce708200a4bc8.zip |
...
Diffstat (limited to 'test/common/io/UnixFileStreamTest.cpp')
-rw-r--r-- | test/common/io/UnixFileStreamTest.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/test/common/io/UnixFileStreamTest.cpp b/test/common/io/UnixFileStreamTest.cpp deleted file mode 100644 index cdc749ba..00000000 --- a/test/common/io/UnixFileStreamTest.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "cru/common/io/OpenFileFlag.hpp" -#include "cru/common/platform/unix/UnixFileStream.hpp" - -#include <gtest/gtest.h> - -#include <cstdio> -#include <filesystem> - -TEST(UnixFileStream, Work) { - 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(); - mktemp(temp_file_path.data()); - - String path = String::FromUtf8(temp_file_path); - - UnixFileStream file(path, OpenFileFlags::Write | OpenFileFlags::Create); - file.Write("abc", 3); - file.Close(); - - UnixFileStream file2(path, OpenFileFlags::Read); - auto buffer = std::make_unique<std::byte[]>(3); - file2.Read(buffer.get(), 3); - ASSERT_EQ(std::string_view(reinterpret_cast<const char*>(buffer.get()), 3), - "abc"); - file2.Close(); - - std::filesystem::remove(temp_file_path); -} |