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/util/io/illegal_input_error.hpp | 62 +++++++++ libstdc++-v3/testsuite/util/io/prog_bar.cc | 79 +++++++++++ libstdc++-v3/testsuite/util/io/prog_bar.hpp | 86 ++++++++++++ libstdc++-v3/testsuite/util/io/text_populate.hpp | 153 +++++++++++++++++++++ .../testsuite/util/io/verified_cmd_line_input.cc | 106 ++++++++++++++ .../testsuite/util/io/verified_cmd_line_input.hpp | 67 +++++++++ libstdc++-v3/testsuite/util/io/xml.hpp | 121 ++++++++++++++++ .../testsuite/util/io/xml_test_formatter.hpp | 78 +++++++++++ 8 files changed, 752 insertions(+) create mode 100644 libstdc++-v3/testsuite/util/io/illegal_input_error.hpp create mode 100644 libstdc++-v3/testsuite/util/io/prog_bar.cc create mode 100644 libstdc++-v3/testsuite/util/io/prog_bar.hpp create mode 100644 libstdc++-v3/testsuite/util/io/text_populate.hpp create mode 100644 libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc create mode 100644 libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp create mode 100644 libstdc++-v3/testsuite/util/io/xml.hpp create mode 100644 libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp (limited to 'libstdc++-v3/testsuite/util/io') diff --git a/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp b/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp new file mode 100644 index 000000000..79f003b77 --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp @@ -0,0 +1,62 @@ +// -*- C++ -*- + +// Copyright (C) 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file illegal_input_error.hpp + * Contains an input exception. + */ + +#ifndef PB_DS_ILLEGAL_INPUT_EX_HPP +#define PB_DS_ILLEGAL_INPUT_EX_HPP + +#include + +namespace __gnu_pbds +{ + namespace test + { + class illegal_input_error : public std::exception + { }; + + // Substitute for concurrence_error object in the case of -fno-exceptions. + inline void + __throw_illegal_input_error() + { +#if __EXCEPTIONS + throw illegal_input_error(); +#else + __builtin_abort(); +#endif + } + } // namespace test +} // namespace __gnu_pbds + +#endif // #ifndef PB_DS_ILLEGAL_INPUT_EX_HPP diff --git a/libstdc++-v3/testsuite/util/io/prog_bar.cc b/libstdc++-v3/testsuite/util/io/prog_bar.cc new file mode 100644 index 000000000..9b73298e0 --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/prog_bar.cc @@ -0,0 +1,79 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file prog_bar.cpp + * Contains a progress bar - idea taken from boost::timer by Beman Dawes. + */ + +#include + +namespace __gnu_pbds +{ + namespace test + { + prog_bar:: + prog_bar(size_t max, std::ostream& r_os, bool display/*= true*/) : + m_cur(0), + m_max(max), + m_cur_disp(0), + m_r_os(r_os), + m_display(display) + { + if (m_display == false) + return; + + for (std::size_t i = 0; i < num_disp; ++i) + m_r_os << "-"; + + m_r_os << std::endl; + } + + void + prog_bar:: + inc() + { + ++m_cur; + + if (m_display == false) + return; + + while (m_cur * num_disp >= m_max * m_cur_disp && m_cur_disp < num_disp) + { + m_r_os << '*'; + m_r_os.flush(); + ++m_cur_disp; + } + } + + } // namespace test + +} // namespace __gnu_pbds diff --git a/libstdc++-v3/testsuite/util/io/prog_bar.hpp b/libstdc++-v3/testsuite/util/io/prog_bar.hpp new file mode 100644 index 000000000..0d4b44853 --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/prog_bar.hpp @@ -0,0 +1,86 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file prog_bar.hpp + * Contains a progress bar - idea taken from boost::timer by Beman Dawes. + */ + +#ifndef PB_DS_PROG_BAR_HPP +#define PB_DS_PROG_BAR_HPP + +#include +#include +#include + +namespace __gnu_pbds +{ + + namespace test + { + + /** + * Progress bar. + * Simplified from part of boost::timer by Beman Dawes. + **/ + class prog_bar + { + protected: + enum{num_disp = 40}; + + public: + prog_bar(size_t max, std::ostream& r_os, bool display = true); + + void + inc(); + + private: + prog_bar(const prog_bar& ); + + prog_bar& + operator=(const prog_bar& ); + + private: + size_t m_cur; + const size_t m_max; + + size_t m_cur_disp; + + std::ostream& m_r_os; + + bool m_display; + }; + + } // namespace test + +} // namespace __gnu_pbds + +#endif // #ifndef PB_DS_PROG_BAR_HPP diff --git a/libstdc++-v3/testsuite/util/io/text_populate.hpp b/libstdc++-v3/testsuite/util/io/text_populate.hpp new file mode 100644 index 000000000..97731dd9f --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/text_populate.hpp @@ -0,0 +1,153 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file text_populate.hpp + * Contains a function for populating a vector with text words from + * a file. + */ + +#ifndef PB_DS_TEXT_POPULATE_HPP +#define PB_DS_TEXT_POPULATE_HPP + +#include +#include +#include +#include +#include + +namespace __gnu_pbds +{ + + namespace test + { + + template + void + text_populate(const std::string& r_f_name, Vec& r_a_txt) + { + const size_t size = r_a_txt.size(); + + try + { + std::ifstream f(r_f_name.c_str()); + + if (!f.good()) + { + std::cerr << "Cannot open file " << r_f_name.c_str() << + std::endl; + + throw __gnu_pbds::test::illegal_input_error(); + } + + size_t i = 0; + + while (f.good()&& i < size) + { + f >> r_a_txt[i].first; + r_a_txt[i].second = 0; + + ++i; + } + + if (i < size) + { + std::cerr << "Read only " << static_cast(i) << + " words" << std::endl; + + throw __gnu_pbds::test::illegal_input_error(); + } + } + catch(...) + { + std::cerr << "Error reading from file" << std::endl; + + throw; + } + } + + template + void + distinct_text_populate(const std::string& r_f_name, Vec& r_a_txt) + { + const size_t size = r_a_txt.size(); + + try + { + std::ifstream f(r_f_name.c_str()); + + if (!f.good()) + { + std::cerr << "Cannot open file " << r_f_name.c_str() << + std::endl; + + throw __gnu_pbds::test::illegal_input_error(); + } + + typedef std::set< typename Vec::value_type::first_type> set_t; + + set_t s; + + while (f.good()&& s.size() < size) + { + typename Vec::value_type::first_type v; + + f >> v; + + if (s.find(v) == s.end()) + { + r_a_txt[s.size()] = std::make_pair(v, 0); + + s.insert(v); + } + } + + if (s.size() < size) + { + std::cerr << "Read only " << static_cast(s.size()) << + " words" << std::endl; + + throw __gnu_pbds::test::illegal_input_error(); + } + } + catch(...) + { + std::cerr << "Error reading from file" << std::endl; + + throw; + } + } + + } // namespace test + +} // namespace __gnu_pbds + +#endif // #ifndef PB_DS_TEXT_POPULATE_HPP diff --git a/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc new file mode 100644 index 000000000..3f94a2759 --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc @@ -0,0 +1,106 @@ +// -*- C++ -*- + +// Copyright (C) 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file verified_cmd_line_input.cpp + * Contains definitions for tests - verified command line input. + */ + +#include +#include +#include +#include +#include + +namespace __gnu_pbds +{ + namespace test + { + void + verify_argc(size_t given, size_t required) + { + if (given != required) + __throw_illegal_input_error(); + } + + void + verify_prob(double prob) + { + if (prob < 0 || prob > 1) + __throw_illegal_input_error(); + } + + std::string + get_cmd_line_str(int argc, char* a_p_argv[], int argn) + { + if (argc <= argn) + __throw_illegal_input_error(); + const std::string ret(a_p_argv[argn]); + return ret; + } + + double + get_cmd_line_prob(int argc, char* a_p_argv[], int argn) + { + if (argc <= argn) + __throw_illegal_input_error(); + const double ret = ::atof(a_p_argv[argn]); + verify_prob(ret); + return ret; + } + + size_t + get_cmd_line_size(int argc, char* a_p_argv[], int argn) + { + if (argc <= argn) + __throw_illegal_input_error(); + const size_t ret = static_cast(::atoi(a_p_argv[argn])); + return ret; + } + + bool + get_cmd_line_bool(int argc, char* a_p_argv[], int argn) + { + if (argc <= argn) + __throw_illegal_input_error(); + + const std::string opt(a_p_argv[argn]); + if (opt.size() != 1) + __throw_illegal_input_error(); + if (opt[0] == 't') + return true; + if (opt[0] == 'f') + return false; + __throw_illegal_input_error(); + return false; + } + } // namespace test +} // namespace __gnu_pbds diff --git a/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp new file mode 100644 index 000000000..29651f7ae --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp @@ -0,0 +1,67 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file verified_cmd_line_input.hpp + * Contains definitions for tests - verified command line input. + */ + +#ifndef PB_DS_VERIFIED_CMD_LINE_INPUT_HPP +#define PB_DS_VERIFIED_CMD_LINE_INPUT_HPP + +#include +#include + +namespace __gnu_pbds +{ + namespace test + { + void + verify_argc(size_t given, size_t required); + + void + verify_prob(double prob); + + std::string + get_cmd_line_str(int argc, char* a_p_argv[], int argn); + + double + get_cmd_line_prob(int argc, char* a_p_argv[], int argn); + + size_t + get_cmd_line_size(int argc, char* a_p_argv[], int argn); + + bool + get_cmd_line_bool(int argc, char* a_p_argv[], int argn); + } // namespace test +} // namespace __gnu_pbds + +#endif // #ifndef PB_DS_VERIFIED_CMD_LINE_INPUT_HPP diff --git a/libstdc++-v3/testsuite/util/io/xml.hpp b/libstdc++-v3/testsuite/util/io/xml.hpp new file mode 100644 index 000000000..d945a3bef --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/xml.hpp @@ -0,0 +1,121 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file xml.hpp + * Contains some xml utilities. + */ + +#ifndef PB_DS_XML_HPP +#define PB_DS_XML_HPP + +#include +#include + +namespace __gnu_pbds +{ + namespace test + { + namespace detail + { + std::string + make_xml_name_start_tag(std::string name) + { return ("<" + name); } + + template + std::string + make_xml_attrib_val(std::string attrib, const V val) + { + std::ostringstream sstrm; + sstrm << " " << attrib << " = \"" << val << "\""; + return (sstrm.str()); + } + + std::string + make_xml_name_start_tag_end_delimiter() + { return (">\n"); } + + std::string + make_xml_name_end_tag(std::string name) + { return ("\n"); } + } // namespace detail + + std::string + make_xml_tag(const std::string name, + const std::string data = std::string("")) + { + std::ostringstream sstrm; + sstrm << detail::make_xml_name_start_tag(name); + sstrm << detail::make_xml_name_start_tag_end_delimiter(); + sstrm << data; + sstrm << detail::make_xml_name_end_tag(name); + return sstrm.str(); + } + + template + std::string + make_xml_tag(const std::string name, + const std::string attrib0, + const Val0 val0, + const std::string data = std::string("")) + { + std::ostringstream sstrm; + + sstrm << detail::make_xml_name_start_tag(name); + sstrm << detail::make_xml_attrib_val(attrib0, val0); + sstrm << detail::make_xml_name_start_tag_end_delimiter(); + sstrm << data; + sstrm << detail::make_xml_name_end_tag(name); + return sstrm.str(); + } + + template + std::string + make_xml_tag(const std::string name, + const std::string attrib0, + const Val0 val0, + const std::string attrib1, + const Val1 val1, + const std::string data = std::string("")) + { + std::ostringstream sstrm; + sstrm << detail::make_xml_name_start_tag(name); + sstrm << detail::make_xml_attrib_val(attrib0, val0); + sstrm << detail::make_xml_attrib_val(attrib1, val1); + sstrm << detail::make_xml_name_start_tag_end_delimiter(); + sstrm << data; + sstrm << detail::make_xml_name_end_tag(name); + return sstrm.str(); + } + } // namespace test +} // namespace __gnu_pbds + +#endif // #ifndef PB_DS_XML_HPP diff --git a/libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp b/libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp new file mode 100644 index 000000000..b06d3e49d --- /dev/null +++ b/libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp @@ -0,0 +1,78 @@ +// -*- C++ -*- + +// Copyright (C) 2005, 2006, 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 +// . + + +// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. + +// Permission to use, copy, modify, sell, and distribute this software +// is hereby granted without fee, provided that the above copyright +// notice appears in all copies, and that both that copyright notice +// and this permission notice appear in supporting documentation. None +// of the above authors, nor IBM Haifa Research Laboratories, make any +// representation about the suitability of this software for any +// purpose. It is provided "as is" without express or implied +// warranty. + +/** + * @file xml_test_formatter.hpp + * Contains an XML formatter for tests. + */ + +#ifndef PB_DS_XML_TEST_FORMATTER_HPP +#define PB_DS_XML_TEST_FORMATTER_HPP + +#include +#include +#include + +namespace __gnu_pbds +{ + namespace test + { + struct xml_test_formatter + { + xml_test_formatter() + { + std::cout << "" << std::endl; + std::cout << "" << std::endl; + } + + virtual + ~xml_test_formatter() + { std::cout << "" << std::endl; } + }; + + struct xml_result_set_formatter + { + xml_result_set_formatter(const std::string& name, const std::string& desc) + { + std::cout << detail::make_xml_name_start_tag("cntnr"); + std::cout << detail::make_xml_attrib_val("name", name); + std::cout << detail::make_xml_name_start_tag_end_delimiter(); + std::cout << make_xml_tag("desc", desc); + } + + virtual + ~xml_result_set_formatter() + { std::cout << "" << std::endl; } + }; + } // namespace test +} // namespace __gnu_pbds + +#endif // #ifndef PB_DS_XML_TEST_FORMATTER_HPP -- cgit v1.2.3