diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2022-03-03 14:12:07 -0500 |
---|---|---|
committer | Ryan Ofsky <ryan@ofsky.org> | 2022-03-03 14:12:07 -0500 |
commit | 2f5fd3cf9225aed439d1de767312bb340972d665 (patch) | |
tree | 509a2404960c0460c7e7452b7225b748538f7524 /src/test/fs_tests.cpp | |
parent | 08bcfa27675da5c65e4c9eab7e7764eab0599298 (diff) | |
download | bitcoin-2f5fd3cf9225aed439d1de767312bb340972d665.tar.xz |
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 <falke.marco@gmail.com> in
https://github.com/bitcoin/bitcoin/pull/24306#discussion_r818566106
Diffstat (limited to 'src/test/fs_tests.cpp')
-rw-r--r-- | src/test/fs_tests.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/fs_tests.cpp b/src/test/fs_tests.cpp index 5875f0218f..d2554483d4 100644 --- a/src/test/fs_tests.cpp +++ b/src/test/fs_tests.cpp @@ -46,8 +46,8 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream) { fs::path tmpfolder = m_args.GetDataDirBase(); // tmpfile1 should be the same as tmpfile2 - fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃"; - fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃"; + fs::path tmpfile1 = tmpfolder / fs::u8path("fs_tests_₿_🏃"); + fs::path tmpfile2 = tmpfolder / fs::u8path("fs_tests_₿_🏃"); { std::ofstream file{tmpfile1}; file << "bitcoin"; @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream) } { // Join an absolute path and a relative path. - fs::path p = fsbridge::AbsPathJoin(tmpfolder, "fs_tests_₿_🏃"); + fs::path p = fsbridge::AbsPathJoin(tmpfolder, fs::u8path("fs_tests_₿_🏃")); BOOST_CHECK(p.is_absolute()); BOOST_CHECK_EQUAL(tmpfile1, p); } |