Skip to content

Commit 2f5fd3c

Browse files
committed
test: Correctly decode UTF-8 literal string paths
Call fs::u8path to convert some UTF-8 string literals to paths, instead of relying on implicit conversions. The implicit conversions incorrectly decode const char* paths using the current windows codepage, instead of treating them as UTF-8. This could cause test failures depending what environment windows tests are run in. Issue was reported by MarcoFalke <[email protected]> in bitcoin/bitcoin#24306 (comment)
1 parent 08bcfa2 commit 2f5fd3c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/test/fs_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
4646
{
4747
fs::path tmpfolder = m_args.GetDataDirBase();
4848
// tmpfile1 should be the same as tmpfile2
49-
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
50-
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
49+
fs::path tmpfile1 = tmpfolder / fs::u8path("fs_tests_₿_🏃");
50+
fs::path tmpfile2 = tmpfolder / fs::u8path("fs_tests_₿_🏃");
5151
{
5252
std::ofstream file{tmpfile1};
5353
file << "bitcoin";
@@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
8686
}
8787
{
8888
// Join an absolute path and a relative path.
89-
fs::path p = fsbridge::AbsPathJoin(tmpfolder, "fs_tests_₿_🏃");
89+
fs::path p = fsbridge::AbsPathJoin(tmpfolder, fs::u8path("fs_tests_₿_🏃"));
9090
BOOST_CHECK(p.is_absolute());
9191
BOOST_CHECK_EQUAL(tmpfile1, p);
9292
}

0 commit comments

Comments
 (0)