xref: /llvm-project/libcxx/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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: c++98, c++03
10 
11 // <string>
12 
13 // basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
14 
15 #include <string>
16 #include <cassert>
17 
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20 
21 int main()
22 {
23     {
24         std::string s = {'a', 'b', 'c'};
25         assert(s == "abc");
26     }
27     {
28         std::wstring s;
29         s = {L'a', L'b', L'c'};
30         assert(s == L"abc");
31     }
32     {
33         typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
34         S s = {'a', 'b', 'c'};
35         assert(s == "abc");
36     }
37     {
38         typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
39         S s;
40         s = {L'a', L'b', L'c'};
41         assert(s == L"abc");
42     }
43 }
44