Skip to content

Commit fa00098

Browse files
author
MarcoFalke
committed
Add tests for C++20 std::u8string
Also, add missing includes: #include <system_error> // for error_code #include <type_traits> // for is_same #include <cerrno> // for errno
1 parent fa2bac0 commit fa00098

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/test/fs_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
1818
BOOST_AUTO_TEST_CASE(fsbridge_pathtostring)
1919
{
2020
std::string u8_str = "fs_tests_₿_🏃";
21+
std::u8string str8{u8"fs_tests_₿_🏃"};
2122
BOOST_CHECK_EQUAL(fs::PathToString(fs::PathFromString(u8_str)), u8_str);
2223
BOOST_CHECK_EQUAL(fs::u8path(u8_str).u8string(), u8_str);
24+
BOOST_CHECK_EQUAL(fs::path(str8).u8string(), u8_str);
2325
BOOST_CHECK_EQUAL(fs::PathFromString(u8_str).u8string(), u8_str);
2426
BOOST_CHECK_EQUAL(fs::PathToString(fs::u8path(u8_str)), u8_str);
2527
#ifndef WIN32
@@ -47,7 +49,7 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
4749
fs::path tmpfolder = m_args.GetDataDirBase();
4850
// tmpfile1 should be the same as tmpfile2
4951
fs::path tmpfile1 = tmpfolder / fs::u8path("fs_tests_₿_🏃");
50-
fs::path tmpfile2 = tmpfolder / fs::u8path("fs_tests_₿_🏃");
52+
fs::path tmpfile2 = tmpfolder / fs::path(u8"fs_tests_₿_🏃");
5153
{
5254
std::ofstream file{tmpfile1};
5355
file << "bitcoin";

src/util/fs.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2022 The Bitcoin Core developers
1+
// Copyright (c) 2017-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -18,6 +18,7 @@
1818
#endif
1919

2020
#include <cassert>
21+
#include <cerrno>
2122
#include <string>
2223

2324
namespace fsbridge {
@@ -130,4 +131,4 @@ std::string get_filesystem_error_message(const fs::filesystem_error& e)
130131
#endif
131132
}
132133

133-
} // fsbridge
134+
} // namespace fsbridge

src/util/fs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2022 The Bitcoin Core developers
1+
// Copyright (c) 2017-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -14,6 +14,8 @@
1414
#include <ios>
1515
#include <ostream>
1616
#include <string>
17+
#include <system_error>
18+
#include <type_traits>
1719
#include <utility>
1820

1921
/** Filesystem operations and types */

0 commit comments

Comments
 (0)