1053d81ceSMarshall Clow //===----------------------------------------------------------------------===// 2053d81ceSMarshall Clow // 357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6053d81ceSMarshall Clow // 7053d81ceSMarshall Clow //===----------------------------------------------------------------------===// 8053d81ceSMarshall Clow 9a7f9895cSLouis Dionne // UNSUPPORTED: no-localization 10*4fc50236SJoe Loser // UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14) 1188ffc727SLouis Dionne 1202d11757SLouis Dionne // <string_view> 13053d81ceSMarshall Clow 14053d81ceSMarshall Clow // template<class charT, class traits, class Allocator> 15053d81ceSMarshall Clow // basic_ostream<charT, traits>& 16053d81ceSMarshall Clow // operator<<(basic_ostream<charT, traits>& os, 17053d81ceSMarshall Clow // const basic_string_view<charT,traits> str); 18053d81ceSMarshall Clow 19053d81ceSMarshall Clow #include <string_view> 20053d81ceSMarshall Clow #include <sstream> 21053d81ceSMarshall Clow #include <cassert> 22053d81ceSMarshall Clow 237fc6a556SMarshall Clow #include "test_macros.h" 247fc6a556SMarshall Clow main(int,char **)252df59c50SJF Bastienint main(int, char**) 26053d81ceSMarshall Clow { 27053d81ceSMarshall Clow { 28053d81ceSMarshall Clow std::ostringstream out; 29f4c1258dSLouis Dionne std::string_view sv("some text"); 30053d81ceSMarshall Clow out << sv; 31053d81ceSMarshall Clow assert(out.good()); 32053d81ceSMarshall Clow assert(sv == out.str()); 33053d81ceSMarshall Clow } 34053d81ceSMarshall Clow { 35053d81ceSMarshall Clow std::ostringstream out; 36053d81ceSMarshall Clow std::string s("some text"); 37f4c1258dSLouis Dionne std::string_view sv(s); 38053d81ceSMarshall Clow out.width(12); 39053d81ceSMarshall Clow out << sv; 40053d81ceSMarshall Clow assert(out.good()); 41053d81ceSMarshall Clow assert(" " + s == out.str()); 42053d81ceSMarshall Clow } 43f4c1258dSLouis Dionne #ifndef TEST_HAS_NO_WIDE_CHARACTERS 44053d81ceSMarshall Clow { 45053d81ceSMarshall Clow std::wostringstream out; 46f4c1258dSLouis Dionne std::wstring_view sv(L"some text"); 47053d81ceSMarshall Clow out << sv; 48053d81ceSMarshall Clow assert(out.good()); 49053d81ceSMarshall Clow assert(sv == out.str()); 50053d81ceSMarshall Clow } 51053d81ceSMarshall Clow { 52053d81ceSMarshall Clow std::wostringstream out; 53053d81ceSMarshall Clow std::wstring s(L"some text"); 54f4c1258dSLouis Dionne std::wstring_view sv(s); 55053d81ceSMarshall Clow out.width(12); 56053d81ceSMarshall Clow out << sv; 57053d81ceSMarshall Clow assert(out.good()); 58053d81ceSMarshall Clow assert(L" " + s == out.str()); 59053d81ceSMarshall Clow } 60f4c1258dSLouis Dionne #endif 612df59c50SJF Bastien 622df59c50SJF Bastien return 0; 63053d81ceSMarshall Clow } 64