mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-02 18:29:17 +08:00
refs #81, work on incomplete string_view support when using c++17
This commit is contained in:
parent
97577f4c3b
commit
eef2c2ba55
3
.clang-tidy
Normal file
3
.clang-tidy
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
Checks: -modernize-use-nodiscard
|
||||
...
|
@ -1569,14 +1569,14 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 1), int>::type size = 1>
|
||||
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
||||
template <typename strT, typename std::enable_if<path::_is_basic_string<strT>::value && (sizeof(typename strT::value_type) == 1), int>::type size = 1>
|
||||
inline std::string toUtf8(const strT& unicodeString)
|
||||
{
|
||||
return std::string(unicodeString.begin(), unicodeString.end());
|
||||
}
|
||||
|
||||
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 2), int>::type size = 2>
|
||||
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
||||
template <typename strT, typename std::enable_if<path::_is_basic_string<strT>::value && (sizeof(typename strT::value_type) == 2), int>::type size = 2>
|
||||
inline std::string toUtf8(const strT& unicodeString)
|
||||
{
|
||||
std::string result;
|
||||
for (auto iter = unicodeString.begin(); iter != unicodeString.end(); ++iter) {
|
||||
@ -1604,8 +1604,8 @@ inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicode
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename charT, typename traits, typename Alloc, typename std::enable_if<(sizeof(charT) == 4), int>::type size = 4>
|
||||
inline std::string toUtf8(const std::basic_string<charT, traits, Alloc>& unicodeString)
|
||||
template <typename strT, typename std::enable_if<path::_is_basic_string<strT>::value && (sizeof(typename strT::value_type) == 4), int>::type size = 4>
|
||||
inline std::string toUtf8(const strT& unicodeString)
|
||||
{
|
||||
std::string result;
|
||||
for (auto c : unicodeString) {
|
||||
|
@ -44,6 +44,23 @@ else()
|
||||
endif()
|
||||
ParseAndAddCatchTests(filesystem_test_wchar)
|
||||
endif()
|
||||
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
|
||||
add_executable(filesystem_test_cpp17 filesystem_test.cpp catch.hpp)
|
||||
set_property(TARGET filesystem_test_cpp17 PROPERTY CXX_STANDARD 17)
|
||||
target_link_libraries(filesystem_test_cpp17 ghc_filesystem)
|
||||
target_compile_options(filesystem_test_cpp17 PRIVATE
|
||||
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
target_compile_definitions(filesystem_test_cpp17 PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(filesystem_test_cpp17 PROPERTIES LINK_FLAGS "-g4 -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1")
|
||||
endif()
|
||||
ParseAndAddCatchTests(filesystem_test_cpp17)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(multifile_test multi1.cpp multi2.cpp catch.hpp)
|
||||
|
@ -2689,6 +2689,7 @@ TEST_CASE("30.10.15.39 weakly_canonical", "[filesystem][operations][fs.op.weakly
|
||||
TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
|
||||
{
|
||||
#if __cpp_lib_string_view
|
||||
using namespace std::literals;
|
||||
{
|
||||
std::string p("foo/bar");
|
||||
std::string_view sv(p);
|
||||
@ -2698,7 +2699,11 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
|
||||
CHECK(p2 == "foo");
|
||||
CHECK(p2.compare(std::string_view("foo")) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
auto p = fs::path{"XYZ"};
|
||||
p /= "Appendix"sv;
|
||||
CHECK(p == "XYZ/Appendix");
|
||||
}
|
||||
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
|
||||
{
|
||||
std::wstring p(L"foo/bar");
|
||||
|
Loading…
x
Reference in New Issue
Block a user