Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion tests/System/IO/tm_ostream_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,56 @@ TEST_CASE ("cout/cerr") {
cerr << "棒棒糖" << LF;
}

TEST_MEMORY_LEAK_ALL
TEST_MEMORY_LEAK_ALL

TEST_CASE ("tm_ostream opened on file") {
url file_path= url_temp ("lolly_test_output.txt");
string content = "Hello from tm_ostream file test!";

{
tm_ostream out (file_path);
CHECK (out->is_writable () == true);
out << content;
}

string loaded= "";
load_string (file_path, loaded, false);
CHECK (loaded == content);

remove (file_path);
}

TEST_CASE ("tm_ostream file with utf-8 filename") {
url file_path= url_temp ("lolly_utf8_棒棒糖.txt");
string content = "utf-8 content";

{
tm_ostream out (file_path);
CHECK (out->is_writable () == true);
out << content;
}

string loaded= "";
load_string (file_path, loaded, false);
CHECK (loaded == content);

remove (file_path);
}

TEST_CASE ("tm_ostream interoperability with load_string and save_string") {
url file_path= url_temp ("lolly_interop_test.txt");
string content = "interoperability test content";

save_string (file_path, content, false);

{
tm_ostream out (file_path);
CHECK (out->is_writable () == true);
}

string loaded= "";
load_string (file_path, loaded, false);
CHECK (loaded == content);

remove (file_path);
}