source.pass.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // UNSUPPORTED: c++98, c++03
  10. // <experimental/filesystem>
  11. // class path
  12. // template <class Source>
  13. // path(const Source& source);
  14. // template <class InputIterator>
  15. // path(InputIterator first, InputIterator last);
  16. #include <experimental/filesystem>
  17. #include <type_traits>
  18. #include <cassert>
  19. #include "test_macros.h"
  20. #include "test_iterators.h"
  21. #include "min_allocator.h"
  22. #include "filesystem_test_helper.hpp"
  23. namespace fs = std::experimental::filesystem;
  24. template <class CharT>
  25. void RunTestCase(MultiStringType const& MS) {
  26. using namespace fs;
  27. const char* Expect = MS;
  28. const CharT* TestPath = MS;
  29. const CharT* TestPathEnd = StrEnd(TestPath);
  30. const std::size_t Size = TestPathEnd - TestPath;
  31. const std::size_t SSize = StrEnd(Expect) - Expect;
  32. assert(Size == SSize);
  33. // StringTypes
  34. {
  35. const std::basic_string<CharT> S(TestPath);
  36. path p(S);
  37. assert(p.native() == Expect);
  38. assert(p.string<CharT>() == TestPath);
  39. assert(p.string<CharT>() == S);
  40. }
  41. // Char* pointers
  42. {
  43. path p(TestPath);
  44. assert(p.native() == Expect);
  45. assert(p.string<CharT>() == TestPath);
  46. }
  47. {
  48. path p(TestPath, TestPathEnd);
  49. assert(p.native() == Expect);
  50. assert(p.string<CharT>() == TestPath);
  51. }
  52. // Iterators
  53. {
  54. using It = input_iterator<const CharT*>;
  55. path p(It{TestPath});
  56. assert(p.native() == Expect);
  57. assert(p.string<CharT>() == TestPath);
  58. }
  59. {
  60. using It = input_iterator<const CharT*>;
  61. path p(It{TestPath}, It{TestPathEnd});
  62. assert(p.native() == Expect);
  63. assert(p.string<CharT>() == TestPath);
  64. }
  65. }
  66. int main() {
  67. for (auto const& MS : PathList) {
  68. RunTestCase<char>(MS);
  69. RunTestCase<wchar_t>(MS);
  70. RunTestCase<char16_t>(MS);
  71. RunTestCase<char32_t>(MS);
  72. }
  73. }