// 2009-07-15 Paolo Carlini // // Copyright (C) 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . // 27.6.1.2.2 arithmetic extractors #include #include #include // DR 696. void test01() { using namespace std; bool test __attribute__((unused)) = true; short s1 = 0; wostringstream oss1; oss1 << numeric_limits::max(); wistringstream iss1(oss1.str()); iss1 >> s1; VERIFY( s1 == numeric_limits::max() ); VERIFY( !iss1.fail() && iss1.eof() ); short s2 = 0; wostringstream oss2; oss2 << static_cast(numeric_limits::max()) + 1; wistringstream iss2(oss2.str()); iss2 >> s2; VERIFY( s2 == numeric_limits::max() ); VERIFY( iss2.fail() && iss2.eof() ); short s3 = 0; wostringstream oss3; oss3 << numeric_limits::min(); wistringstream iss3(oss3.str()); iss3 >> s3; VERIFY( s3 == numeric_limits::min() ); VERIFY( !iss3.fail() && iss3.eof() ); short s4 = 0; wostringstream oss4; oss4 << static_cast(numeric_limits::min()) - 1; wistringstream iss4(oss4.str()); iss4 >> s4; VERIFY( s4 == numeric_limits::min() ); VERIFY( iss4.fail() && iss4.eof() ); int i1 = 0; wostringstream oss5; oss5 << numeric_limits::max(); wistringstream iss5(oss5.str()); iss5 >> i1; VERIFY( i1 == numeric_limits::max() ); VERIFY( !iss5.fail() && iss5.eof() ); int i2 = 0; wostringstream oss6; oss6 << static_cast(numeric_limits::max()) + 1; wistringstream iss6(oss6.str()); iss6 >> i2; VERIFY( i1 == numeric_limits::max() ); VERIFY( iss6.fail() && iss6.eof() ); int i3 = 0; wostringstream oss7; oss7 << numeric_limits::min(); wistringstream iss7(oss7.str()); iss7 >> i3; VERIFY( i3 == numeric_limits::min() ); VERIFY( !iss7.fail() && iss7.eof() ); int i4 = 0; wostringstream oss8; oss8 << static_cast(numeric_limits::min()) - 1; wistringstream iss8(oss8.str()); iss8 >> i4; VERIFY( i4 == numeric_limits::min() ); VERIFY( iss8.fail() && iss8.eof() ); } int main() { test01(); return 0; }