From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/22_locale/num_get/get/char/4.cc | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 libstdc++-v3/testsuite/22_locale/num_get/get/char/4.cc (limited to 'libstdc++-v3/testsuite/22_locale/num_get/get/char/4.cc') diff --git a/libstdc++-v3/testsuite/22_locale/num_get/get/char/4.cc b/libstdc++-v3/testsuite/22_locale/num_get/get/char/4.cc new file mode 100644 index 000000000..b480ac698 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/num_get/get/char/4.cc @@ -0,0 +1,110 @@ +// 2001-11-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation +// +// 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 +// . + +// 22.2.2.1.1 num_get members + +#include +#include +#include + +// 2002-01-10 David Seymour +// libstdc++/5331 +void test04() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + // Check num_get works with other iterators besides streambuf + // output iterators. (As long as output_iterator requirements are met.) + typedef string::const_iterator iter_type; + typedef num_get num_get_type; + const ios_base::iostate goodbit = ios_base::goodbit; + ios_base::iostate err = ios_base::goodbit; + const locale loc_c = locale::classic(); + const string str("20000106 Elizabeth Durack"); + const string str2("0 true 0xbffff74c Durack"); + + istringstream iss; // need an ios, add my num_get facet + iss.imbue(locale(loc_c, new num_get_type)); + + // Iterator advanced, state, output. + const num_get_type& ng = use_facet(iss.getloc()); + + // 01 get(long) + // 02 get(long double) + // 03 get(bool) + // 04 get(void*) + + // 01 get(long) + long i = 0; + err = goodbit; + iter_type end1 = ng.get(str.begin(), str.end(), iss, err, i); + string rem1(end1, str.end()); + VERIFY( err == goodbit ); + VERIFY( i == 20000106); + VERIFY( rem1 == " Elizabeth Durack" ); + + // 02 get(long double) + long double ld = 0.0; + err = goodbit; + iter_type end2 = ng.get(str.begin(), str.end(), iss, err, ld); + string rem2(end2, str.end()); + VERIFY( err == goodbit ); + VERIFY( ld == 20000106); + VERIFY( rem2 == " Elizabeth Durack" ); + + // 03 get(bool) + bool b = 1; + iss.clear(); + err = goodbit; + iter_type end3 = ng.get(str2.begin(), str2.end(), iss, err, b); + string rem3(end3, str2.end()); + VERIFY( err == goodbit ); + VERIFY( b == 0 ); + VERIFY( rem3 == " true 0xbffff74c Durack" ); + + iss.clear(); + err = goodbit; + iss.setf(ios_base::boolalpha); + iter_type end4 = ng.get(++end3, str2.end(), iss, err, b); + string rem4(end4, str2.end()); + VERIFY( err == goodbit ); + VERIFY( b == true ); + VERIFY( rem4 == " 0xbffff74c Durack" ); + + // 04 get(void*) + void* v; + iss.clear(); + err = goodbit; + iss.setf(ios_base::fixed, ios_base::floatfield); + iter_type end5 = ng.get(++end4, str2.end(), iss, err, v); + string rem5(end5, str2.end()); + VERIFY( err == goodbit ); + VERIFY( b == true ); + VERIFY( rem5 == " Durack" ); +} + +int main() +{ + test04(); + return 0; +} + + +// Kathleen Hannah, humanitarian, woman, art-thief -- cgit v1.2.3