]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/experimental/filesystem/class.path/path.member/path.construct/source.pass.cpp
Vendor import of libc++ release_39 branch r276489:
[FreeBSD/FreeBSD.git] / test / std / experimental / filesystem / class.path / path.member / path.construct / source.pass.cpp
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 Source>
17 //      path(const Source& source);
18 // template <class InputIterator>
19 //      path(InputIterator first, InputIterator last);
20
21
22 #include <experimental/filesystem>
23 #include <type_traits>
24 #include <cassert>
25
26 #include "test_macros.h"
27 #include "test_iterators.h"
28 #include "min_allocator.h"
29 #include "filesystem_test_helper.hpp"
30
31 namespace fs = std::experimental::filesystem;
32
33 template <class CharT>
34 void RunTestCase(MultiStringType const& MS) {
35   using namespace fs;
36   const char* Expect = MS;
37   const CharT* TestPath = MS;
38   const CharT* TestPathEnd = StrEnd(TestPath);
39   const std::size_t Size = TestPathEnd - TestPath;
40   const std::size_t SSize = StrEnd(Expect) - Expect;
41   assert(Size == SSize);
42   // StringTypes
43   {
44     const std::basic_string<CharT> S(TestPath);
45     path p(S);
46     assert(p.native() == Expect);
47     assert(p.string<CharT>() == TestPath);
48     assert(p.string<CharT>() == S);
49   }
50   // Char* pointers
51   {
52     path p(TestPath);
53     assert(p.native() == Expect);
54     assert(p.string<CharT>() == TestPath);
55   }
56   {
57     path p(TestPath, TestPathEnd);
58     assert(p.native() == Expect);
59     assert(p.string<CharT>() == TestPath);
60   }
61   // Iterators
62   {
63     using It = input_iterator<const CharT*>;
64     path p(It{TestPath});
65     assert(p.native() == Expect);
66     assert(p.string<CharT>() == TestPath);
67   }
68   {
69     using It = input_iterator<const CharT*>;
70     path p(It{TestPath}, It{TestPathEnd});
71     assert(p.native() == Expect);
72     assert(p.string<CharT>() == TestPath);
73   }
74 }
75
76 int main() {
77   for (auto const& MS : PathList) {
78     RunTestCase<char>(MS);
79     RunTestCase<wchar_t>(MS);
80     RunTestCase<char16_t>(MS);
81     RunTestCase<char32_t>(MS);
82   }
83 }