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>
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 using std::string_view;
25 using std::wstring_view;
26 
main(int,char **)27 int main(int, char**)
28 {
29     {
30         std::ostringstream out;
31         string_view sv("some text");
32         out << sv;
33         assert(out.good());
34         assert(sv == out.str());
35     }
36     {
37         std::ostringstream out;
38         std::string s("some text");
39         string_view sv(s);
40         out.width(12);
41         out << sv;
42         assert(out.good());
43         assert("   " + s == out.str());
44     }
45     {
46         std::wostringstream out;
47         wstring_view sv(L"some text");
48         out << sv;
49         assert(out.good());
50         assert(sv == out.str());
51     }
52     {
53         std::wostringstream out;
54         std::wstring s(L"some text");
55         wstring_view sv(s);
56         out.width(12);
57         out << sv;
58         assert(out.good());
59         assert(L"   " + s == out.str());
60     }
61 
62   return 0;
63 }
64