brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · a469609 Raw
78 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS11 12// <filesystem>13 14// template <class Source>15//    path u8path(Source const&);16// template <class InputIter>17//   path u8path(InputIter, InputIter);18 19#include <filesystem>20#include <cassert>21#include <string>22#include <type_traits>23 24#include "test_macros.h"25#include "test_iterators.h"26#include "count_new.h"27namespace fs = std::filesystem;28 29int main(int, char**)30{31  using namespace fs;32  const char* In1 = "abcd/efg";33  const std::string In2(In1);34  const auto In3 = In2.begin();35  const auto In3End = In2.end();36  {37    path p = fs::u8path(In1);38    assert(p == In1);39  }40  {41    path p = fs::u8path(In2);42    assert(p == In1);43  }44  {45    path p = fs::u8path(In2.data());46    assert(p == In1);47  }48  {49    path p = fs::u8path(In3, In3End);50    assert(p == In1);51  }52#if TEST_STD_VER > 17 && defined(__cpp_char8_t) && defined(_LIBCPP_VERSION) && !defined(TEST_HAS_NO_LOCALIZATION)53  const char8_t* u8In1 = u8"abcd/efg";54  const std::u8string u8In2(u8In1);55  const auto u8In3 = u8In2.begin();56  const auto u8In3End = u8In2.end();57  // Proposed in P1423, marked tested only for libc++58  {59    path p = fs::u8path(u8In1);60    assert(p == In1);61  }62  {63    path p = fs::u8path(u8In2);64    assert(p == In1);65  }66  {67    path p = fs::u8path(u8In2.data());68    assert(p == In1);69  }70  {71    path p = fs::u8path(u8In3, u8In3End);72    assert(p == In1);73  }74#endif75 76  return 0;77}78