]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/8.cc
9152ad9a8d4e6ee09f571e0ad5ea754473d4771d
1 // Copyright (C) 2016 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++11 } }
21 #include <testsuite_hooks.h>
23 template<typename
... Args
>
25 construct(Args
&&... args
)
27 return std::wstring( std::forward
<Args
>(args
)... ).length();
33 bool test
__attribute__((unused
)) = true;
35 using string
= std::wstring
;
36 using list
= std::initializer_list
<string::value_type
>;
38 const std::wstring lvalue
= L
"lvalue";
39 std::allocator
<char> alloc
;
41 // test all valid combinations of arguments:
42 VERIFY( construct( ) == 0 );
43 VERIFY( construct( alloc
) == 0 );
44 VERIFY( construct( lvalue
) == 6 );
45 VERIFY( construct( string
{L
"rvalue"} ) == 6 );
46 VERIFY( construct( lvalue
, 2 ) == 4 );
47 VERIFY( construct( lvalue
, 2, alloc
) == 4 );
48 VERIFY( construct( lvalue
, 2, 3 ) == 3 );
49 VERIFY( construct( lvalue
, 2, 3, alloc
) == 3 );
50 VERIFY( construct( L
"C string", 4 ) == 4 );
51 VERIFY( construct( L
"C string", 4, alloc
) == 4 );
52 VERIFY( construct( L
"C string" ) == 8 );
53 VERIFY( construct( L
"C string and alloc", alloc
) == 18 );
54 VERIFY( construct( 5, L
' ' ) == 5 );
55 VERIFY( construct( 5, L
' ', alloc
) == 5 );
56 VERIFY( construct( lvalue
.begin(), lvalue
.end() ) == 6 );
57 VERIFY( construct( lvalue
.begin(), lvalue
.end(), alloc
) == 6 );
58 VERIFY( construct( list
{ L
'l' , L
'i' , L
's', L
't' } ) == 4 );
59 VERIFY( construct( list
{ L
'l', L
'i', L
's', L
't' }, alloc
) == 4 );
60 #if _GLIBCXX_USE_CXX11_ABI
61 VERIFY( construct( lvalue
, alloc
) == 6 );
62 VERIFY( construct( string
{L
"rvalue"}, alloc
) == 6 );