|
31 | 31 | //---------------------------------------------------------------------------------------
|
32 | 32 | #include <algorithm>
|
33 | 33 | #include <cstdio>
|
| 34 | +#include <cstring> |
34 | 35 | #include <fstream>
|
35 | 36 | #include <functional>
|
36 | 37 | #include <iostream>
|
| 38 | +#include <iomanip> |
37 | 39 | #include <random>
|
| 40 | +#include <sstream> |
38 | 41 | #include <thread>
|
39 | 42 | #ifndef WIN32
|
40 | 43 | #include <sys/socket.h>
|
@@ -197,6 +200,41 @@ static bool has_host_root_name_support()
|
197 | 200 | return fs::path("//host").has_root_name();
|
198 | 201 | }
|
199 | 202 |
|
| 203 | + |
| 204 | +template <class T> |
| 205 | +class TestAllocator |
| 206 | +{ |
| 207 | +public: |
| 208 | + using value_type = T; |
| 209 | + |
| 210 | + TestAllocator() noexcept {} |
| 211 | + template <class U> TestAllocator(TestAllocator<U> const&) noexcept {} |
| 212 | + |
| 213 | + value_type* allocate(std::size_t n) |
| 214 | + { |
| 215 | + return static_cast<value_type*>(::operator new (n*sizeof(value_type))); |
| 216 | + } |
| 217 | + |
| 218 | + void deallocate(value_type* p, std::size_t) noexcept |
| 219 | + { |
| 220 | + ::operator delete(p); |
| 221 | + } |
| 222 | +}; |
| 223 | + |
| 224 | +template <class T, class U> |
| 225 | +bool operator==(TestAllocator<T> const&, TestAllocator<U> const&) noexcept |
| 226 | +{ |
| 227 | + return true; |
| 228 | +} |
| 229 | + |
| 230 | +template <class T, class U> |
| 231 | +bool operator!=(TestAllocator<T> const& x, TestAllocator<U> const& y) noexcept |
| 232 | +{ |
| 233 | + return !(x == y); |
| 234 | +} |
| 235 | + |
| 236 | + |
| 237 | + |
200 | 238 | TEST_CASE("Temporary Directory", "[temp dir]")
|
201 | 239 | {
|
202 | 240 | fs::path tempPath;
|
@@ -424,12 +462,16 @@ TEST_CASE("30.10.8.4.7 path generic format observers", "[filesystem][path][fs.pa
|
424 | 462 | {
|
425 | 463 | #ifdef GHC_OS_WINDOWS
|
426 | 464 | CHECK(fs::u8path("\xc3\xa4\\\xe2\x82\xac").generic_string() == std::string("\xc3\xa4/\xe2\x82\xac"));
|
| 465 | + auto t = fs::u8path("\xc3\xa4\\\xe2\x82\xac").generic_string<char, std::char_traits<char>, TestAllocator<char>>() |
| 466 | + CHECK(t.c_str() == std::string("\xc3\xa4/\xe2\x82\xac")); |
427 | 467 | CHECK(fs::u8path("\xc3\xa4\\\xe2\x82\xac").generic_wstring() == std::wstring(L"\U000000E4/\U000020AC"));
|
428 | 468 | CHECK(fs::u8path("\xc3\xa4\\\xe2\x82\xac").generic_u8string() == std::string("\xc3\xa4/\xe2\x82\xac"));
|
429 | 469 | CHECK(fs::u8path("\xc3\xa4\\\xe2\x82\xac").generic_u16string() == std::u16string(u"\u00E4/\u20AC"));
|
430 | 470 | CHECK(fs::u8path("\xc3\xa4\\\xe2\x82\xac").generic_u32string() == std::u32string(U"\U000000E4/\U000020AC"));
|
431 | 471 | #else
|
432 | 472 | CHECK(fs::u8path("\xc3\xa4/\xe2\x82\xac").generic_string() == std::string(u8"\xc3\xa4/\xe2\x82\xac"));
|
| 473 | + auto t = fs::u8path("\xc3\xa4/\xe2\x82\xac").generic_string<char, std::char_traits<char>, TestAllocator<char>>(); |
| 474 | + CHECK(t.c_str() == std::string(u8"\xc3\xa4/\xe2\x82\xac")); |
433 | 475 | CHECK(fs::u8path("\xc3\xa4/\xe2\x82\xac").generic_wstring() == std::wstring(L"ä/€"));
|
434 | 476 | CHECK(fs::u8path("\xc3\xa4/\xe2\x82\xac").generic_u8string() == std::string(u8"\xc3\xa4/\xe2\x82\xac"));
|
435 | 477 | CHECK(fs::u8path("\xc3\xa4/\xe2\x82\xac").generic_u16string() == std::u16string(u"\u00E4/\u20AC"));
|
|
0 commit comments