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/27_io/basic_ios/cons/2020.cc | 54 +++++++ .../testsuite/27_io/basic_ios/cons/char/1.cc | 79 ++++++++++ .../testsuite/27_io/basic_ios/cons/char/2.cc | 52 +++++++ .../testsuite/27_io/basic_ios/cons/char/3.cc | 169 +++++++++++++++++++++ 4 files changed, 354 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_ios/cons/2020.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ios/cons/char/1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ios/cons/char/2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_ios/cons/char/3.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_ios/cons') diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/cons/2020.cc b/libstdc++-v3/testsuite/27_io/basic_ios/cons/2020.cc new file mode 100644 index 000000000..31f712166 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ios/cons/2020.cc @@ -0,0 +1,54 @@ +// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 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.8.1.1 - Template class basic_filebuf +// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES. + +#include +#include +#include + +// libstdc++/2020 +// should be able to use custom char_type, custom traits type +class gnu_ios: public std::basic_ios<__gnu_test::pod_ushort> +{ }; + +void test07() +{ + bool test __attribute__((unused)) = true; + + try + { gnu_ios obj; } + catch(std::exception& obj) + { + test = false; + VERIFY( test ); + } +} + +int main() +{ + test07(); + return 0; +} + + + +// more surf!!! diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/1.cc new file mode 100644 index 000000000..0796ecfa5 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/1.cc @@ -0,0 +1,79 @@ +// 1999-07-23 bkoz + +// Copyright (C) 1999, 2003, 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.4.4.1 basic_ios constructors + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + std::string str_01("jade cove, big sur"); + std::string str_05; + std::stringbuf strb_01; + std::stringbuf strb_02(str_01, std::ios_base::in); + std::stringbuf strb_03(str_01, std::ios_base::out); + const std::ios_base::fmtflags flag01 = std::ios_base::skipws | + std::ios_base::dec; + std::ios_base::fmtflags flag02; + const std::locale glocale = std::locale(); + + // explicit basic_ios(streambuf* sb) + std::ios ios_00(0); + std::ios ios_01(&strb_01); + std::ios ios_02(&strb_02); + std::ios ios_03(&strb_03); + + // basic_ios() + // NB: This is protected so need to go through fstream + + // void init(sreambuf* sb) + // NB: This is protected so need to go through fstream/stringstream + // Can double-check the accuracy of the above initializations though. + VERIFY( ios_00.rdbuf() == 0 ); + VERIFY( ios_00.tie() == 0 ); + VERIFY( ios_00.rdstate() == std::ios_base::badbit ); + VERIFY( ios_00.exceptions() == std::ios_base::goodbit ); + flag02 = ios_00.flags(); + VERIFY( flag02 == flag01 ); + VERIFY( ios_00.width() == 0 ); + VERIFY( ios_00.precision() == 6 ); + VERIFY( ios_00.fill() == ios_00.widen(' ') ); + VERIFY( ios_00.getloc() == glocale ); + + VERIFY( ios_01.rdbuf() == &strb_01 ); + VERIFY( ios_01.tie() == 0 ); + VERIFY( ios_01.rdstate() == std::ios_base::goodbit ); + VERIFY( ios_01.exceptions() == std::ios_base::goodbit ); + flag02 = ios_01.flags(); + VERIFY( flag02 == flag01 ); + VERIFY( ios_01.width() == 0 ); + VERIFY( ios_01.precision() == 6 ); + VERIFY( ios_01.fill() == ios_01.widen(' ') ); + VERIFY( ios_01.getloc() == glocale ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/2.cc new file mode 100644 index 000000000..d498936f0 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/2.cc @@ -0,0 +1,52 @@ +// 2001-06-05 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 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.4.2.1.6 class ios_base::init + +#include +#include + +// Non-required instantiations don't have the required facets inbued, +// by default, into the locale object. +// See 27.4.4.1 +class gnu_ios: public std::basic_ios { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + + // 01: Doesn't call basic_ios::init, which uses ctype.. + // This should be unambiguously correct. + try + { + gnu_ios gios; + } + catch(...) + { + test = false; + } + VERIFY( test ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/3.cc b/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/3.cc new file mode 100644 index 000000000..bcbe8b737 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_ios/cons/char/3.cc @@ -0,0 +1,169 @@ +// 2001-06-05 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 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.4.2.1.6 class ios_base::init + +#include +#include +#include +#include + +// char_traits specialization +namespace std +{ + template<> + struct char_traits + { + typedef unsigned short char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type&) + { return char_type(); } + + static int_type + to_int_type(const char_type&) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; +} // namespace std + +// Non-required instantiations don't have the required facets inbued, +// by default, into the locale object. +// See 27.4.4.1 + +void test02() +{ + bool test __attribute__((unused)) = true; + + // 02: Calls basic_ios::init, which may call ctype... + try + { + std::basic_string str; + std::basic_ostringstream oss(str); + + // Try each member functions for unformatted io. + // put + oss.put(324); + + // write + const unsigned short us[4] = {1246, 433, 520, 0}; + oss.write(us, 4); + + // flush + oss.flush(); + } + catch(const std::bad_cast& obj) + { + // Should be able to do the above without calling fill() and + // forcing a call to widen... + test = false; + } + catch(...) + { + test = false; + } + VERIFY( test ); +} + +#if !__GXX_WEAK__ +// Explicitly instantiate for systems with no COMDAT or weak support. +template + const std::basic_string::size_type + std::basic_string::_Rep::_S_max_size; + +template + const unsigned short + std::basic_string::_Rep::_S_terminal; +#endif + +int main() +{ + test02(); + return 0; +} -- cgit v1.2.3