Skip to content
Merged
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
22 changes: 20 additions & 2 deletions cpp/src/arrow/io/file_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,28 @@ TEST_F(TestFileOutputStream, FileNameWideCharConversionRangeException) {
ASSERT_RAISES(Invalid, FileOutputStream::Open(file_name));
ASSERT_RAISES(Invalid, ReadableFile::Open(file_name));
}

// TODO add a test with a valid utf-8 filename
#endif

TEST_F(TestFileOutputStream, FileNameValidUtf8) {
// Test that file operations work with UTF-8 filenames (Korean + emoji).
// 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
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
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 = "test content";
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());
}

TEST_F(TestFileOutputStream, DestructorClosesFile) {
int fd_file;

Expand Down
Loading