]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/3.cc
Update copyright in libstdc++-v3.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / inserters_arithmetic / wchar_t / 3.cc
1 // Copyright (C) 2005-2013 Free Software Foundation, Inc.
2 //
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)
7 // any later version.
8
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.
13
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/>.
17
18 #include <sstream>
19 #include <limits>
20 #include <testsuite_hooks.h>
21
22 template<typename T>
23 bool
24 test03_check(T n)
25 {
26 using namespace std;
27 bool test __attribute__((unused)) = true;
28
29 wstringbuf strbuf;
30 wostream o(&strbuf);
31 const wchar_t *expect;
32
33 if (numeric_limits<T>::digits + 1 == 16)
34 expect = L"177777 ffff";
35 else if (numeric_limits<T>::digits + 1 == 32)
36 expect = L"37777777777 ffffffff";
37 else if (numeric_limits<T>::digits + 1 == 64)
38 expect = L"1777777777777777777777 ffffffffffffffff";
39 else
40 expect = L"wow, you've got some big numbers here";
41
42 o << oct << n << L' ' << hex << n;
43 VERIFY ( strbuf.str() == expect );
44
45 return test;
46 }
47
48 void
49 test03()
50 {
51 short s = -1;
52 int i = -1;
53 long l = -1;
54
55 test03_check(s);
56 test03_check(i);
57 test03_check(l);
58 }
59
60 int
61 main()
62 {
63 test03();
64 return 0;
65 }