]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc
re PR libstdc++/37522 (Incorrect vswprintf prototype breaks __to_xstring)
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / numeric_conversions / char / to_string.cc
1 // { dg-options "-std=gnu++0x" }
2 // { dg-require-string-conversions "" }
3
4 // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
5
6 // Copyright (C) 2008 Free Software Foundation, Inc.
7 //
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 2, or (at your option)
12 // any later version.
13
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING. If not, write to the Free
21 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // USA.
23
24 // 21.4 Numeric Conversions [string.conversions]
25
26 #include <string>
27 #include <testsuite_hooks.h>
28
29 void
30 test01()
31 {
32 bool test __attribute__((unused)) = true;
33 using namespace std;
34
35 long long ll1 = -2;
36 string one(to_string(ll1));
37 VERIFY( one == "-2" );
38
39 long long ll2 = 10;
40 string two(to_string(ll2));
41 VERIFY( two == "10" );
42
43 unsigned long long ull1 = 2;
44 string three(to_string(ull1));
45 VERIFY( three == "2" );
46
47 unsigned long long ull2 = 3000;
48 string four(to_string(ull2));
49 VERIFY( four == "3000" );
50
51 long double ld1 = 2.0L;
52 string five(to_string(ld1));
53 VERIFY( five == "2.000000" );
54
55 long double ld2 = -4.0L;
56 string six(to_string(ld2));
57 VERIFY( six == "-4.000000" );
58 }
59
60 int main()
61 {
62 test01();
63 return 0;
64 }