public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5423] libstdc++: Improve tests for stringstream constructors in C++20 Date: Fri, 19 Nov 2021 20:24:15 +0000 (GMT) [thread overview] Message-ID: <20211119202415.BF74C385C409@sourceware.org> (raw) https://gcc.gnu.org/g:be08d573177b2004706759eedfdd4113f69e4c5c commit r12-5423-gbe08d573177b2004706759eedfdd4113f69e4c5c Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Nov 19 13:33:24 2021 +0000 libstdc++: Improve tests for stringstream constructors in C++20 This ensures all constructors are checked. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_istringstream/cons/char/1.cc: Check all constructors. * testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise. * testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise. * testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc: Likewise. Diff: --- .../27_io/basic_istringstream/cons/char/1.cc | 119 +++++++++++++++++--- .../27_io/basic_istringstream/cons/wchar_t/1.cc | 119 +++++++++++++++++--- .../27_io/basic_ostringstream/cons/char/1.cc | 121 +++++++++++++++++--- .../27_io/basic_ostringstream/cons/wchar_t/1.cc | 122 ++++++++++++++++++--- .../27_io/basic_stringstream/cons/char/1.cc | 121 +++++++++++++++++--- .../27_io/basic_stringstream/cons/wchar_t/1.cc | 119 +++++++++++++++++--- 6 files changed, 633 insertions(+), 88 deletions(-) diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc index bfd56b98dff..a3c736eba0c 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons +// C++20 29.8.3.2 basic_istringstream constructors [istringstream.cons] // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } @@ -49,29 +49,120 @@ test02() void test03() { - using alloc_type = __gnu_test::tracker_allocator<char>; - using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>; + using C = char; + using alloc_type = __gnu_test::uneq_allocator<C>; + using traits_type = std::char_traits<C>; + using string = std::basic_string<C, traits_type, alloc_type>; + using istringstream = std::basic_istringstream<C, traits_type, alloc_type>; auto const mode = std::ios_base::in; - str_type s1(cstr); + alloc_type a1(1); + const string s1(cstr, a1); + // basic_istringstream() { - std::istringstream::allocator_type a; - std::istringstream sbuf(s1, mode, a); - std::string s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + istringstream ss; + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_istringstream(openmode) { - std::istringstream sbuf(s1, mode); - std::string s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + istringstream ss(mode); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_istringstream(const basic_string<C,T,A>&, openmode = in) { - std::istringstream sbuf(s1); - std::string s2(cstr); - VERIFY( sbuf.str() == s2 ); + istringstream ss(s1); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(const basic_string<C,T,A>&, openmode = in) + { + istringstream ss(s1, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(openmode, const A&) + { + istringstream ss(mode, a1); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(basic_string<C,T,A>&&, openmode = in) + { + istringstream ss(string{s1}); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(basic_string<C,T,A>&&, openmode = in) + { + istringstream ss(string(s1), mode); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + istringstream ss(s1, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + const std::string s2 = cstr; + istringstream ss(s2, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + istringstream ss(s1, mode, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + const std::string s2 = cstr; + istringstream ss(s2, mode, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, openmode = in) + { + alloc_type a0; + const std::string s2 = cstr; + istringstream ss(s2, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } } diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc index 5573a72311d..a3c1afe6aa2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons +// C++20 29.8.3.2 basic_istringstream constructors [istringstream.cons] // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } @@ -49,29 +49,120 @@ test02() void test03() { - using alloc_type = __gnu_test::tracker_allocator<wchar_t>; - using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>; + using C = wchar_t; + using alloc_type = __gnu_test::uneq_allocator<C>; + using traits_type = std::char_traits<C>; + using string = std::basic_string<C, traits_type, alloc_type>; + using istringstream = std::basic_istringstream<C, traits_type, alloc_type>; auto const mode = std::ios_base::in; - str_type s1(cstr); + alloc_type a1(1); + const string s1(cstr, a1); + // basic_istringstream() { - std::wistringstream::allocator_type a; - std::wistringstream sbuf(s1, mode, a); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + istringstream ss; + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_istringstream(openmode) { - std::wistringstream sbuf(s1, mode); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + istringstream ss(mode); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_istringstream(const basic_string<C,T,A>&, openmode = in) { - std::wistringstream sbuf(s1); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + istringstream ss(s1); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(const basic_string<C,T,A>&, openmode = in) + { + istringstream ss(s1, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(openmode, const A&) + { + istringstream ss(mode, a1); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(basic_string<C,T,A>&&, openmode = in) + { + istringstream ss(string{s1}); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(basic_string<C,T,A>&&, openmode = in) + { + istringstream ss(string(s1), mode); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + istringstream ss(s1, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + const std::wstring s2 = cstr; + istringstream ss(s2, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + istringstream ss(s1, mode, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + const std::wstring s2 = cstr; + istringstream ss(s2, mode, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_istringstream(const basic_string<C,T,SA>&, openmode = in) + { + alloc_type a0; + const std::wstring s2 = cstr; + istringstream ss(s2, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } } diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc index 93d35756a74..a337916441e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons +// C++20 29.8.4.2 basic_ostringstream constructors [ostringstream.cons] // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } @@ -49,29 +49,120 @@ test02() void test03() { - using alloc_type = __gnu_test::tracker_allocator<char>; - using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>; + using C = char; + using alloc_type = __gnu_test::uneq_allocator<C>; + using traits_type = std::char_traits<C>; + using string = std::basic_string<C, traits_type, alloc_type>; + using ostringstream = std::basic_ostringstream<C, traits_type, alloc_type>; - auto const mode = std::ios_base::out; - str_type s1(cstr); + auto const mode = std::ios_base::in; + alloc_type a1(1); + const string s1(cstr, a1); + // basic_ostringstream() { - std::ostringstream::allocator_type a; - std::ostringstream sbuf(s1, mode, a); - std::string s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + ostringstream ss; + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_ostringstream(openmode) { - std::ostringstream sbuf(s1, mode); - std::string s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + ostringstream ss(mode); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_ostringstream(const basic_string<C,T,A>&, openmode = in) { - std::ostringstream sbuf(s1); - std::string s2(cstr); - VERIFY( sbuf.str() == s2 ); + ostringstream ss(s1); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(const basic_string<C,T,A>&, openmode = in) + { + ostringstream ss(s1, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(openmode, const A&) + { + ostringstream ss(mode, a1); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(basic_string<C,T,A>&&, openmode = in) + { + ostringstream ss(string{s1}); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(basic_string<C,T,A>&&, openmode = in) + { + ostringstream ss(string(s1), mode); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + ostringstream ss(s1, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + const std::string s2 = cstr; + ostringstream ss(s2, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + ostringstream ss(s1, mode, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + const std::string s2 = cstr; + ostringstream ss(s2, mode, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, openmode = in) + { + alloc_type a0; + const std::string s2 = cstr; + ostringstream ss(s2, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } } diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc index 12767c781d7..12e40a79740 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons +// C++20 29.8.4.2 basic_ostringstream constructors [ostringstream.cons] // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } @@ -49,32 +49,122 @@ test02() void test03() { - using alloc_type = __gnu_test::tracker_allocator<wchar_t>; - using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>; + using C = wchar_t; + using alloc_type = __gnu_test::uneq_allocator<C>; + using traits_type = std::char_traits<C>; + using string = std::basic_string<C, traits_type, alloc_type>; + using ostringstream = std::basic_ostringstream<C, traits_type, alloc_type>; - auto const mode = std::ios_base::out; - str_type s1(cstr); + auto const mode = std::ios_base::in; + alloc_type a1(1); + const string s1(cstr, a1); + // basic_ostringstream() { - std::wostringstream::allocator_type a; - std::wostringstream sbuf(s1, mode, a); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + ostringstream ss; + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_ostringstream(openmode) { - std::wostringstream sbuf(s1, mode); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + ostringstream ss(mode); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_ostringstream(const basic_string<C,T,A>&, openmode = in) { - std::wostringstream sbuf(s1); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + ostringstream ss(s1); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(const basic_string<C,T,A>&, openmode = in) + { + ostringstream ss(s1, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(openmode, const A&) + { + ostringstream ss(mode, a1); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(basic_string<C,T,A>&&, openmode = in) + { + ostringstream ss(string{s1}); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(basic_string<C,T,A>&&, openmode = in) + { + ostringstream ss(string(s1), mode); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + ostringstream ss(s1, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + const std::wstring s2 = cstr; + ostringstream ss(s2, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + ostringstream ss(s1, mode, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + const std::wstring s2 = cstr; + ostringstream ss(s2, mode, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); } -} + // basic_ostringstream(const basic_string<C,T,SA>&, openmode = in) + { + alloc_type a0; + const std::wstring s2 = cstr; + ostringstream ss(s2, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); + } +} int main() { diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc index 7cb9f34ca04..6395ae3e242 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons +// C++20 29.8.5.2 basic_stringstream constructors [stringstream.cons] // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } @@ -49,29 +49,120 @@ test02() void test03() { - using alloc_type = __gnu_test::tracker_allocator<char>; - using str_type = std::basic_string<char, std::char_traits<char>, alloc_type>; + using C = char; + using alloc_type = __gnu_test::uneq_allocator<C>; + using traits_type = std::char_traits<C>; + using string = std::basic_string<C, traits_type, alloc_type>; + using stringstream = std::basic_stringstream<C, traits_type, alloc_type>; - auto const mode = std::ios_base::in | std::ios_base::out; - str_type s1(cstr); + auto const mode = std::ios_base::in; + alloc_type a1(1); + const string s1(cstr, a1); + // basic_stringstream() { - std::stringstream::allocator_type a; - std::stringstream ss(s1, mode, a); - std::string s2(cstr); - VERIFY( ss.str() == s2 ); + alloc_type a0; + stringstream ss; + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_stringstream(openmode) { - std::stringstream ss(s1, mode); - std::string s2(cstr); - VERIFY( ss.str() == s2 ); + alloc_type a0; + stringstream ss(mode); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_stringstream(const basic_string<C,T,A>&, openmode = in) { - std::stringstream ss(s1); - std::string s2(cstr); - VERIFY( ss.str() == s2 ); + stringstream ss(s1); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(const basic_string<C,T,A>&, openmode = in) + { + stringstream ss(s1, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(openmode, const A&) + { + stringstream ss(mode, a1); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(basic_string<C,T,A>&&, openmode = in) + { + stringstream ss(string{s1}); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(basic_string<C,T,A>&&, openmode = in) + { + stringstream ss(string(s1), mode); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + stringstream ss(s1, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + const std::string s2 = cstr; + stringstream ss(s2, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + stringstream ss(s1, mode, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + const std::string s2 = cstr; + stringstream ss(s2, mode, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, openmode = in) + { + alloc_type a0; + const std::string s2 = cstr; + stringstream ss(s2, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } } diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc index 5573a72311d..d4c412276cc 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc @@ -15,7 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons +// C++20 29.8.5.2 basic_stringstream constructors [stringstream.cons] // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } @@ -49,29 +49,120 @@ test02() void test03() { - using alloc_type = __gnu_test::tracker_allocator<wchar_t>; - using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>; + using C = wchar_t; + using alloc_type = __gnu_test::uneq_allocator<C>; + using traits_type = std::char_traits<C>; + using string = std::basic_string<C, traits_type, alloc_type>; + using stringstream = std::basic_stringstream<C, traits_type, alloc_type>; auto const mode = std::ios_base::in; - str_type s1(cstr); + alloc_type a1(1); + const string s1(cstr, a1); + // basic_stringstream() { - std::wistringstream::allocator_type a; - std::wistringstream sbuf(s1, mode, a); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + stringstream ss; + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_stringstream(openmode) { - std::wistringstream sbuf(s1, mode); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + alloc_type a0; + stringstream ss(mode); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } + // basic_stringstream(const basic_string<C,T,A>&, openmode = in) { - std::wistringstream sbuf(s1); - std::wstring s2(cstr); - VERIFY( sbuf.str() == s2 ); + stringstream ss(s1); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(const basic_string<C,T,A>&, openmode = in) + { + stringstream ss(s1, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(openmode, const A&) + { + stringstream ss(mode, a1); + VERIFY( ss.str().empty() ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(basic_string<C,T,A>&&, openmode = in) + { + stringstream ss(string{s1}); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(basic_string<C,T,A>&&, openmode = in) + { + stringstream ss(string(s1), mode); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a1 ); + VERIFY( ss.str().get_allocator() == a1 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + stringstream ss(s1, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, const A&) + { + alloc_type a2(2); + const std::wstring s2 = cstr; + stringstream ss(s2, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + stringstream ss(s1, mode, a2); + VERIFY( ss.str() == s1 ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&) + { + alloc_type a2(2); + const std::wstring s2 = cstr; + stringstream ss(s2, mode, a2); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a2 ); + VERIFY( ss.str().get_allocator() == a2 ); + } + + // basic_stringstream(const basic_string<C,T,SA>&, openmode = in) + { + alloc_type a0; + const std::wstring s2 = cstr; + stringstream ss(s2, mode); + VERIFY( ss.str() == cstr ); + VERIFY( ss.rdbuf()->get_allocator() == a0 ); + VERIFY( ss.str().get_allocator() == a0 ); } }
reply other threads:[~2021-11-19 20:24 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211119202415.BF74C385C409@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).