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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: libcpp-has-no-localization
10 
11 // <string_view>
12 
13 // template<class charT, class traits, class Allocator>
14 //   basic_ostream<charT, traits>&
15 //   operator<<(basic_ostream<charT, traits>& os,
16 //              const basic_string_view<charT,traits> str);
17 
18 #include <string_view>
19 #include <sstream>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 int main(int, char**)
25 {
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_CHARACTERS
43     {
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 #endif
60 
61   return 0;
62 }
63