| 1 |
// Copyright (C) 2005-2025 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 |
void |
| 24 |
test03_check(T n) |
| 25 |
{ |
| 26 |
using namespace std; |
| 27 |
|
| 28 |
wstringbuf strbuf; |
| 29 |
wostream o(&strbuf); |
| 30 |
const wchar_t *expect; |
| 31 |
|
| 32 |
if (numeric_limits<T>::digits + 1 == 16) |
| 33 |
expect = L"177777 ffff"; |
| 34 |
else if (numeric_limits<T>::digits + 1 == 32) |
| 35 |
expect = L"37777777777 ffffffff"; |
| 36 |
else if (numeric_limits<T>::digits + 1 == 64) |
| 37 |
expect = L"1777777777777777777777 ffffffffffffffff"; |
| 38 |
else |
| 39 |
expect = L"wow, you've got some big numbers here"; |
| 40 |
|
| 41 |
o << oct << n << L' ' << hex << n; |
| 42 |
VERIFY ( strbuf.str() == expect ); |
| 43 |
} |
| 44 |
|
| 45 |
void |
| 46 |
test03() |
| 47 |
{ |
| 48 |
short s = -1; |
| 49 |
int i = -1; |
| 50 |
long l = -1; |
| 51 |
|
| 52 |
test03_check(s); |
| 53 |
test03_check(i); |
| 54 |
test03_check(l); |
| 55 |
} |
| 56 |
|
| 57 |
int |
| 58 |
main() |
| 59 |
{ |
| 60 |
test03(); |
| 61 |
return 0; |
| 62 |
} |