summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/util/io
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/util/io')
-rw-r--r--libstdc++-v3/testsuite/util/io/illegal_input_error.hpp62
-rw-r--r--libstdc++-v3/testsuite/util/io/prog_bar.cc79
-rw-r--r--libstdc++-v3/testsuite/util/io/prog_bar.hpp86
-rw-r--r--libstdc++-v3/testsuite/util/io/text_populate.hpp153
-rw-r--r--libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc106
-rw-r--r--libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp67
-rw-r--r--libstdc++-v3/testsuite/util/io/xml.hpp121
-rw-r--r--libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp78
8 files changed, 752 insertions, 0 deletions
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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <exception>
+
+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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <util/io/prog_bar.hpp>
+
+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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <limits.h>
+#include <iostream>
+#include <string>
+
+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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <io/illegal_input_error.hpp>
+#include <set>
+#include <fstream>
+#include <string>
+#include <iostream>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ template<typename Vec>
+ 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<unsigned long>(i) <<
+ " words" << std::endl;
+
+ throw __gnu_pbds::test::illegal_input_error();
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Error reading from file" << std::endl;
+
+ throw;
+ }
+ }
+
+ template<typename Vec>
+ 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<unsigned long>(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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <util/io/verified_cmd_line_input.hpp>
+#include <limits.h>
+#include <utility>
+#include <stdlib.h>
+#include <bits/functexcept.h>
+
+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<size_t>(::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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <io/illegal_input_error.hpp>
+#include <string>
+
+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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <string>
+#include <sstream>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ std::string
+ make_xml_name_start_tag(std::string name)
+ { return ("<" + name); }
+
+ template<typename V>
+ 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 ("</" + name + ">\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<typename Val0>
+ 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<typename Val0, typename Val1>
+ 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
+// <http://www.gnu.org/licenses/>.
+
+
+// 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 <string>
+#include <iostream>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ struct xml_test_formatter
+ {
+ xml_test_formatter()
+ {
+ std::cout << "<?xml version = \"1.0\"?>" << std::endl;
+ std::cout << "<test>" << std::endl;
+ }
+
+ virtual
+ ~xml_test_formatter()
+ { std::cout << "</test>" << 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 << "</cntnr>" << std::endl; }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_XML_TEST_FORMATTER_HPP