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
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) {
// 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 .. :-)..

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());
}
#endif

TEST_F(TestFileOutputStream, DestructorClosesFile) {
Expand Down
Loading