brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 83422ca Raw
77 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 11// These tests require locale for non-char paths12// UNSUPPORTED: no-localization13 14// <filesystem>15 16// class path17 18// std::string  string() const;19// std::wstring wstring() const;20// std::u8string  u8string() const;21// std::u16string u16string() const;22// std::u32string u32string() const;23 24#include <filesystem>25#include <cassert>26#include <string>27#include <type_traits>28 29#include "assert_macros.h"30#include "count_new.h"31#include "make_string.h"32#include "min_allocator.h"33#include "test_iterators.h"34#include "test_macros.h"35namespace fs = std::filesystem;36 37MultiStringType longString = MKSTR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/123456789/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");38 39int main(int, char**)40{41  using namespace fs;42  auto const& MS = longString;43  const char* value = longString;44  const path p(value);45  {46    std::string s = p.string();47    assert(s == value);48  }49  {50#if TEST_STD_VER > 17 && defined(__cpp_char8_t)51    ASSERT_SAME_TYPE(decltype(p.u8string()), std::u8string);52    std::u8string s = p.u8string();53    assert(s == (const char8_t*)MS);54#else55    ASSERT_SAME_TYPE(decltype(p.u8string()), std::string);56    std::string s = p.u8string();57    assert(s == (const char*)MS);58#endif59  }60#ifndef TEST_HAS_NO_WIDE_CHARACTERS61  {62    std::wstring s = p.wstring();63    assert(s == (const wchar_t*)MS);64  }65#endif66  {67    std::u16string s = p.u16string();68    assert(s == (const char16_t*)MS);69  }70  {71    std::u32string s = p.u32string();72    assert(s == (const char32_t*)MS);73  }74 75  return 0;76}77