Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // UNSUPPORTED: c++98, c++03 |
| 11 | |
| 12 | // <experimental/filesystem> |
| 13 | |
| 14 | // class path |
| 15 | |
| 16 | // template <class ECharT, class Traits = char_traits<ECharT>, |
| 17 | // class Allocator = allocator<ECharT>> |
| 18 | // basic_string<ECharT, Traits, Allocator> |
| 19 | // generic_string(const Allocator& a = Allocator()) const; |
| 20 | |
Eric Fiselier | f1471a3 | 2018-03-26 05:46:57 +0000 | [diff] [blame] | 21 | #include "filesystem_include.hpp" |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 22 | #include <type_traits> |
| 23 | #include <cassert> |
| 24 | |
| 25 | #include "test_macros.h" |
| 26 | #include "test_iterators.h" |
| 27 | #include "count_new.hpp" |
| 28 | #include "min_allocator.h" |
| 29 | #include "filesystem_test_helper.hpp" |
| 30 | |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 31 | MultiStringType longString = MKSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/123456789/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
| 32 | |
| 33 | |
| 34 | // generic_string<C, T, A> forwards to string<C, T, A>. Tests for |
| 35 | // string<C, T, A>() are in "path.native.op/string_alloc.pass.cpp". |
| 36 | // generic_string is minimally tested here. |
| 37 | int main() |
| 38 | { |
| 39 | using namespace fs; |
| 40 | using CharT = wchar_t; |
| 41 | using Traits = std::char_traits<CharT>; |
| 42 | using Alloc = malloc_allocator<CharT>; |
| 43 | using Str = std::basic_string<CharT, Traits, Alloc>; |
| 44 | const wchar_t* expect = longString; |
| 45 | const path p((const char*)longString); |
| 46 | { |
| 47 | DisableAllocationGuard g; |
| 48 | Alloc a; |
| 49 | Alloc::disable_default_constructor = true; |
| 50 | Str s = p.generic_string<wchar_t, Traits, Alloc>(a); |
| 51 | assert(s == expect); |
| 52 | assert(Alloc::alloc_count > 0); |
| 53 | assert(Alloc::outstanding_alloc() == 1); |
| 54 | } |
| 55 | } |