brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · c7772b0 Raw
63 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: no-localization10// UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14)11 12// <string_view>13 14// template<class charT, class traits, class Allocator>15//   basic_ostream<charT, traits>&16//   operator<<(basic_ostream<charT, traits>& os,17//              const basic_string_view<charT,traits> str);18 19#include <string_view>20#include <sstream>21#include <cassert>22 23#include "test_macros.h"24 25int main(int, char**) {26  {27    std::ostringstream out;28    std::string_view sv("some text");29    out << sv;30    assert(out.good());31    assert(sv == out.str());32  }33  {34    std::ostringstream out;35    std::string s("some text");36    std::string_view sv(s);37    out.width(12);38    out << sv;39    assert(out.good());40    assert("   " + s == out.str());41  }42#ifndef TEST_HAS_NO_WIDE_CHARACTERS43  {44    std::wostringstream out;45    std::wstring_view sv(L"some text");46    out << sv;47    assert(out.good());48    assert(sv == out.str());49  }50  {51    std::wostringstream out;52    std::wstring s(L"some text");53    std::wstring_view sv(s);54    out.width(12);55    out << sv;56    assert(out.good());57    assert(L"   " + s == out.str());58  }59#endif60 61  return 0;62}63