diff options
| author | Yuqian Yang <crupest@crupest.life> | 2026-03-07 20:42:37 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2026-03-07 20:42:37 +0800 |
| commit | 38756822825e20eca3b9e01b735946175223d692 (patch) | |
| tree | fc2a495bfc0e082d5ed9a1642278ae6467fe2742 /test/base/platform | |
| parent | 924f4b472712d0cfc55b81dcb3eaed3f8a478288 (diff) | |
| download | cru-38756822825e20eca3b9e01b735946175223d692.tar.gz cru-38756822825e20eca3b9e01b735946175223d692.tar.bz2 cru-38756822825e20eca3b9e01b735946175223d692.zip | |
Refactor stream.
Diffstat (limited to 'test/base/platform')
| -rw-r--r-- | test/base/platform/win/StreamTest.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/test/base/platform/win/StreamTest.cpp b/test/base/platform/win/StreamTest.cpp index f42fc5c2..56761b14 100644 --- a/test/base/platform/win/StreamTest.cpp +++ b/test/base/platform/win/StreamTest.cpp @@ -1,3 +1,4 @@ +#include "cru/base/Guard.h" #include "cru/base/StringUtil.h" #include "cru/base/platform/win/Stream.h" @@ -15,6 +16,7 @@ TEST_CASE("StreamConvert FileStreamWork", "[stream]") { (std::filesystem::temp_directory_path() / "cru_test_temp.XXXXXX") .native(); _wmktemp(temp_file_path.data()); + Guard _([temp_file_path] { std::filesystem::remove(temp_file_path); }); std::string path = string::ToUtf8String(temp_file_path); @@ -32,8 +34,6 @@ TEST_CASE("StreamConvert FileStreamWork", "[stream]") { REQUIRE(std::string_view(buffer.get(), 3) == "abc"); com_stream->Release(); file2.Close(); - - std::filesystem::remove(temp_file_path); } TEST_CASE("ComStream Work", "[stream]") { @@ -45,6 +45,7 @@ TEST_CASE("ComStream Work", "[stream]") { (std::filesystem::temp_directory_path() / "cru_test_temp.XXXXXX") .native(); _wmktemp(temp_file_path.data()); + Guard _([temp_file_path] { std::filesystem::remove(temp_file_path); }); std::string path = string::ToUtf8String(temp_file_path); @@ -62,6 +63,4 @@ TEST_CASE("ComStream Work", "[stream]") { REQUIRE(std::string_view(reinterpret_cast<const char*>(buffer.get()), 3) == "abc"); file2.Close(); - - std::filesystem::remove(temp_file_path); } |
