Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled wchar_t path Source on UNIX #103

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
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
7 changes: 0 additions & 7 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,19 +402,12 @@ class GHC_FS_API_CLASS path

template <typename T1, typename T2 = void>
using path_type = typename std::enable_if<!std::is_same<path, T1>::value, path>::type;
#ifdef GHC_USE_WCHAR_T
template <typename T>
using path_from_string = typename std::enable_if<_is_basic_string<T>::value || std::is_same<char const*, typename std::decay<T>::type>::value || std::is_same<char*, typename std::decay<T>::type>::value ||
std::is_same<wchar_t const*, typename std::decay<T>::type>::value || std::is_same<wchar_t*, typename std::decay<T>::type>::value,
path>::type;
template <typename T>
using path_type_EcharT = typename std::enable_if<std::is_same<T, char>::value || std::is_same<T, char16_t>::value || std::is_same<T, char32_t>::value, path>::type;
#else
template <typename T>
using path_from_string = typename std::enable_if<_is_basic_string<T>::value || std::is_same<char const*, typename std::decay<T>::type>::value || std::is_same<char*, typename std::decay<T>::type>::value, path>::type;
template <typename T>
using path_type_EcharT = typename std::enable_if<std::is_same<T, char>::value || std::is_same<T, char16_t>::value || std::is_same<T, char32_t>::value || std::is_same<T, wchar_t>::value, path>::type;
#endif
// 30.10.8.4.1 constructors and destructor
path() noexcept;
path(const path& p);
Expand Down
16 changes: 10 additions & 6 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ TEST_CASE("30.10.8.4.2 path assignments", "[filesystem][path][fs.path.assign]")
REQUIRE(p1 == p3);
p3 = fs::path{"/usr/local"};
REQUIRE(p2 == p3);
p3 = fs::path{L"/usr/local"};
REQUIRE(p2 == p3);
p3.assign(L"/usr/local");
REQUIRE(p2 == p3);
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
p3 = fs::path::string_type{L"/foo/bar"};
REQUIRE(p1 == p3);
Expand Down Expand Up @@ -499,9 +503,13 @@ TEST_CASE("30.10.8.4.4 path concatenation", "[filesystem][path][fs.path.concat]"

CHECK((fs::path("foo") += "bar") == "foobar");
CHECK((fs::path("foo") += "/bar") == "foo/bar");
CHECK((fs::path("foo") += L"bar") == "foobar");
CHECK((fs::path("foo") += L"/bar") == "foo/bar");

CHECK((fs::path("foo") += 'b') == "foob");
CHECK((fs::path("foo") += '/') == "foo/");
CHECK((fs::path("foo") += L'b') == "foob");
CHECK((fs::path("foo") += L'/') == "foo/");

CHECK((fs::path("foo") += std::string("bar")) == "foobar");
CHECK((fs::path("foo") += std::string("/bar")) == "foo/bar");
Expand All @@ -514,6 +522,8 @@ TEST_CASE("30.10.8.4.4 path concatenation", "[filesystem][path][fs.path.concat]"

CHECK(fs::path("foo").concat("bar") == "foobar");
CHECK(fs::path("foo").concat("/bar") == "foo/bar");
CHECK(fs::path("foo").concat(L"bar") == "foobar");
CHECK(fs::path("foo").concat(L"/bar") == "foo/bar");
std::string bar = "bar";
CHECK(fs::path("foo").concat(bar.begin(), bar.end()) == "foobar");
#ifndef USE_STD_FS
Expand Down Expand Up @@ -2745,14 +2755,10 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
#if defined(GHC_HAS_STD_STRING_VIEW)
using namespace std::literals;
using string_view = std::string_view;
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
using wstring_view = std::wstring_view;
#endif
#elif defined(GHC_HAS_STD_EXPERIMENTAL_STRING_VIEW)
using string_view = std::experimental::string_view;
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
using wstring_view = std::experimental::wstring_view;
#endif
#endif

{
Expand All @@ -2769,7 +2775,6 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
p /= string_view("Appendix");
CHECK(p == "XYZ/Appendix");
}
#if defined(IS_WCHAR_PATH) || defined(GHC_USE_WCHAR_T)
{
std::wstring p(L"foo/bar");
wstring_view sv(p);
Expand All @@ -2779,7 +2784,6 @@ TEST_CASE("std::string_view support", "[filesystem][fs.string_view]")
CHECK(p2 == "foo");
CHECK(p2.compare(wstring_view(L"foo")) == 0);
}
#endif

#else
WARN("std::string_view specific tests are empty without std::string_view.");
Expand Down