blob: a757cbb88fdf5aa053680cf2174fbba711a6ca55 [file] [log] [blame]
Eric Fiselier6e9a6942016-06-17 19:46:40 +00001//===----------------------------------------------------------------------===//
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 Fiselierf1471a32018-03-26 05:46:57 +000021#include "filesystem_include.hpp"
Eric Fiselier6e9a6942016-06-17 19:46:40 +000022#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 Fiselier6e9a6942016-06-17 19:46:40 +000031MultiStringType 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.
37int 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}