Skip to content
Merged
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion cpp/src/arrow/io/file_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,25 @@ TEST_F(TestFileOutputStream, FileNameWideCharConversionRangeException) {
ASSERT_RAISES(Invalid, ReadableFile::Open(file_name));
}

// TODO add a test with a valid utf-8 filename
TEST_F(TestFileOutputStream, FileNameValidUtf8) {
Comment thread
HyukjinKwon marked this conversation as resolved.
// Test that file operations work with valid UTF-8 filenames.
// On Windows, PlatformFilename::FromString() converts UTF-8 strings to wide strings.
// On Unix, filenames are treated as opaque byte strings.
std::string utf8_file_name = "test_file_한국어_😀.txt";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한국어 is "Korean" in Korean FYI .. :-)..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the emoticon Korean too? :)

std::string utf8_path = TempFile(utf8_file_name);

ASSERT_OK_AND_ASSIGN(auto file, FileOutputStream::Open(utf8_path));
const char* data = "UTF-8 test data";
Comment thread
HyukjinKwon marked this conversation as resolved.
Outdated
ASSERT_OK(file->Write(data, strlen(data)));
ASSERT_OK(file->Close());

// Verify we can read it back
ASSERT_OK_AND_ASSIGN(auto readable_file, ReadableFile::Open(utf8_path));
ASSERT_OK_AND_ASSIGN(auto buffer, readable_file->ReadAt(0, strlen(data)));
ASSERT_EQ(std::string(reinterpret_cast<const char*>(buffer->data()), buffer->size()),
std::string(data));
ASSERT_OK(readable_file->Close());
}
#endif

TEST_F(TestFileOutputStream, DestructorClosesFile) {
Expand Down
Loading