diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-05-02 18:14:25 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-05-02 18:14:25 +0100 |
commit | a623b6f0116e4d8ad004fcdc665c2395eddc6953 (patch) | |
tree | 9c457b03d3edd9198925dfca2066624c48f127f7 /libstdc++-v3/testsuite | |
parent | 3435c26f32968345c9e2cc5f4e517f955726de1c (diff) | |
download | gcc-a623b6f0116e4d8ad004fcdc665c2395eddc6953.zip gcc-a623b6f0116e4d8ad004fcdc665c2395eddc6953.tar.gz gcc-a623b6f0116e4d8ad004fcdc665c2395eddc6953.tar.bz2 |
iterator: New.
* include/experimental/iterator: New. Define ostream_joiner.
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* testsuite/experimental/iterator/make_ostream_joiner.cc: New.
* testsuite/experimental/iterator/ostream_joiner.cc: New.
* testsuite/experimental/iterator/requirements.cc: New.
* doc/xml/manual/status_cxx2017.xml: Update status.
* doc/html/manual/status.html: Regenerate.
From-SVN: r222727
Diffstat (limited to 'libstdc++-v3/testsuite')
3 files changed, 169 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/experimental/iterator/make_ostream_joiner.cc b/libstdc++-v3/testsuite/experimental/iterator/make_ostream_joiner.cc new file mode 100644 index 0000000..76d3a97 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/iterator/make_ostream_joiner.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2015 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/>. + +// { dg-options "-std=gnu++14" } + +#include <experimental/iterator> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::ostringstream os; + auto joiner = std::experimental::make_ostream_joiner(os, "..."); + for (int i : { 1, 2, 3, 4, 5 }) + *joiner++ = i; + VERIFY( os.str() == "1...2...3...4...5" ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/experimental/iterator/ostream_joiner.cc b/libstdc++-v3/testsuite/experimental/iterator/ostream_joiner.cc new file mode 100644 index 0000000..c78dbe6 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/iterator/ostream_joiner.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2015 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/>. + +// { dg-options "-std=gnu++14" } + +#include <experimental/iterator> +#include <sstream> +#include <testsuite_hooks.h> + +#ifndef __cpp_lib_experimental_ostream_joiner +# error Feature-test macro is not defined. +#elif __cpp_lib_experimental_ostream_joiner < 201411 +# error Feature-test macro has bad value. +#endif + +using std::experimental::ostream_joiner; + +void +test01() +{ + std::ostringstream os; + ostream_joiner<int> joiner{os, 9}; + for (int i : { 1, 2, 3, 4, 5 }) + *joiner++ = i; + VERIFY( os.str() == "192939495" ); +} + +void +test02() +{ + std::ostringstream os; + ostream_joiner<char> joiner{os, ','}; + for (int i : { 1, 2, 3, 4, 5 }) + { + *joiner = i; + ++joiner; + } + VERIFY( os.str() == "1,2,3,4,5" ); +} + +void +test03() +{ +#if _GLIBCXX_USE_WCHAR_T + std::wostringstream os; + ostream_joiner<wchar_t, wchar_t> joiner{os, L','}; + for (int i : { 1, 2, 3, 4, 5 }) + *joiner++ = i; + VERIFY( os.str() == L"1,2,3,4,5" ); +#endif +} + +int +main() +{ + test01(); + test02(); + test03(); +} diff --git a/libstdc++-v3/testsuite/experimental/iterator/requirements.cc b/libstdc++-v3/testsuite/experimental/iterator/requirements.cc new file mode 100644 index 0000000..54a7f8e --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/iterator/requirements.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2015 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/>. + +// { dg-options "-std=gnu++14" } +// { dg-do compile } + +// This is a compile-only test with minimal includes +#include <experimental/iterator> +#include <iosfwd> + +using namespace std::experimental; + +template<typename Delim, typename Char> +struct tester +{ + using joiner_type = ostream_joiner<Delim, Char>; + using ostream_type = std::basic_ostream<Char>; + using test_type = decltype(make_ostream_joiner(std::declval<ostream_type&>(), + std::declval<Delim>())); + + static_assert(is_same_v<test_type, joiner_type>, ""); + + static_assert(is_same_v<typename test_type::char_type, Char>, ""); + + static_assert(is_same_v<typename test_type::traits_type, + std::char_traits<Char>>, ""); + + static_assert(is_same_v<typename test_type::ostream_type, ostream_type>, ""); + + static_assert(is_same_v<typename test_type::iterator_category, + std::output_iterator_tag>, ""); + + static_assert(is_same_v<typename test_type::value_type, void>, ""); + static_assert(is_same_v<typename test_type::difference_type, void>, ""); + static_assert(is_same_v<typename test_type::pointer, void>, ""); + static_assert(is_same_v<typename test_type::reference, void>, ""); +}; + +tester<char, char> cc; +tester<int, char> ic; +#if _GLIBCXX_USE_WCHAR_T +tester<wchar_t, wchar_t> ww; +tester<int, wchar_t> iw; +#endif |