From f2935a671cc49db6140fbbcecf24b6e8ff8d92d6 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 27 Feb 2024 08:51:49 +0200 Subject: [PATCH 001/120] [libc++][spanstream] P0448R4: A `strstream` replacement using `span` as buffer Implements: P0448R https://wg21.link/P0448R4 - https://eel.is/c++draft/span.streams - https://eel.is/c++draft/spanbuf - https://eel.is/c++draft/ispanstream - https://eel.is/c++draft/ospanstream - https://eel.is/c++draft/spanstream --- libcxx/include/CMakeLists.txt | 1 + libcxx/include/spanstream | 428 ++++++++++++++++++ libcxx/include/version | 2 +- libcxx/modules/std.compat.cppm.in | 3 - libcxx/modules/std.cppm.in | 6 +- .../ispanstream.general/lit.local.cfg | 3 + .../nothing_to_do.pass.cpp | 15 + .../ispanstream/types.compile.pass.cpp | 79 ++++ .../ospanstream.general/lit.local.cfg | 3 + .../nothing_to_do.pass.cpp | 15 + .../ospanstream/types.compile.pass.cpp | 79 ++++ .../spanbuf/spanbuf.cons/default.pass.cpp | 45 ++ .../spanbuf/spanbuf.general/lit.local.cfg | 3 + .../spanbuf.general/nothing_to_do.pass.cpp | 15 + .../spanbuf/types.compile.pass.cpp | 79 ++++ .../spanstream.general/lit.local.cfg | 3 + .../spanstream.general/nothing_to_do.pass.cpp | 15 + .../spanstream/types.compile.pass.cpp | 78 ++++ .../spanstream.version.compile.pass.cpp | 68 +++ .../generate_feature_test_macro_components.py | 1 - 20 files changed, 932 insertions(+), 9 deletions(-) create mode 100644 libcxx/include/spanstream create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/lit.local.cfg create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/lit.local.cfg create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/lit.local.cfg create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/lit.local.cfg create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp create mode 100644 libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index cd6583cb62c24..936963e89e97f 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -1056,6 +1056,7 @@ set(files shared_mutex source_location span + spanstream sstream stack stdatomic.h diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream new file mode 100644 index 0000000000000..f25a04c2cb525 --- /dev/null +++ b/libcxx/include/spanstream @@ -0,0 +1,428 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SPANSTREAM +#define _LIBCPP_SPANSTREAM + +// clang-format off + +/* + Span-based streams [span.streams] + + template> + class basic_spanbuf; + + template + void swap(basic_spanbuf& x, basic_spanbuf& y); + + using spanbuf = basic_spanbuf; + using wspanbuf = basic_spanbuf; + + template> + class basic_ispanstream; + + template + void swap(basic_ispanstream& x, basic_ispanstream& y); + + using ispanstream = basic_ispanstream; + using wispanstream = basic_ispanstream; + + template> + class basic_ospanstream; + + template + void swap(basic_ospanstream& x, basic_ospanstream& y); + + using ospanstream = basic_ospanstream; + using wospanstream = basic_ospanstream; + + template> + class basic_spanstream; + + template + void swap(basic_spanstream& x, basic_spanstream& y); + + using spanstream = basic_spanstream; + using wspanstream = basic_spanstream; +*/ + +// clang-format on + +#include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> +#include <__config> +#include <__memory/addressof.h> +#include <__ranges/concepts.h> +#include <__utility/cmp.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +// Class template basic_spanbuf [spanbuf] + +template > +class _LIBCPP_TEMPLATE_VIS basic_spanbuf : public basic_streambuf<_CharT, _Traits> { +public: + using char_type = _CharT; + using int_type = typename _Traits::int_type; + using pos_type = typename _Traits::pos_type; + using off_type = typename _Traits::off_type; + using traits_type = _Traits; + + // [spanbuf.cons], constructors + + _LIBCPP_HIDE_FROM_ABI basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {} + + _LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf(ios_base::openmode __which) + : basic_spanbuf(std::span<_CharT>(), __which) {} + + _LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf(std::span<_CharT> __s, + ios_base::openmode __which = ios_base::in | ios_base::out) + : basic_streambuf<_CharT, _Traits>{}, __mode_{__which}, __buf_{__s} { + this->span(__s); + } + + basic_spanbuf(const basic_spanbuf&) = delete; + _LIBCPP_HIDE_FROM_ABI basic_spanbuf(basic_spanbuf&& __rhs) + : basic_streambuf<_CharT, _Traits>{std::move(__rhs)}, + __mode_{std::move(__rhs.__mode_)}, + __buf_{std::move(__rhs.__buf_)} {} + + // [spanbuf.assign], assignment and swap + + basic_spanbuf& operator=(const basic_spanbuf&) = delete; + _LIBCPP_HIDE_FROM_ABI basic_spanbuf& operator=(basic_spanbuf&& __rhs) { + basic_spanbuf __tmp{std::move(__rhs)}; + this->swap(__tmp); + return *this; + } + + _LIBCPP_HIDE_FROM_ABI void swap(basic_spanbuf& __rhs) { + basic_streambuf<_CharT, _Traits>::swap(__rhs); + std::swap(__mode_, __rhs.__mode_); + std::swap(__buf_, __rhs.__buf_); + } + + // [spanbuf.members], member functions + + _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { + if (__mode_ & ios_base::out) { + return std::span<_CharT>(this->pbase(), this->pptr()); + } + return __buf_; + } + + _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { + __buf_ = __s; + + if (__mode_ & ios_base::out) { + this->setp(__s.data(), __s.data() + __s.size()); + if (__mode_ & ios_base::ate) { + this->pbump(__s.size()); + } + } + + if (__mode_ & ios_base::in) { + this->setg(__s.data(), __s.data(), __s.data() + __s.size()); + } + } + +protected: + // [spanbuf.virtuals], overridden virtual functions + + _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>* setbuf(_CharT* __s, streamsize __n) override { + this->span(std::span<_CharT>(__s, __n)); + return this; + } + + _LIBCPP_HIDE_FROM_ABI pos_type + seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) override { + const pos_type __error(off_type(-1)); + + if ((__which & ios_base::in) && (__which & ios_base::out) && (ios_base::cur == __way)) + return __error; + + off_type __baseoff = [this, __way, __which] { + switch (__way) { + case ios_base::beg: + return off_type(0); + + case ios_base::cur: + if (__which & ios_base::out) + return off_type(this->pptr() - this->pbase()); + return off_type(this->gptr() - this->eback()); + + case ios_base::end: + if ((__which & ios_base::out) && !(__which & ios_base::in)) + return off_type(this->pptr() - this->pbase()); + return off_type(__buf_.size()); + } + }(); + + off_type __newoff; + if (__builtin_add_overflow(__baseoff, __off, &__newoff) || (__newoff < off_type(0)) || + (std::cmp_greater(__newoff, __buf_.size()))) + return __error; + + if (__which & ios_base::in) { + if ((this->gptr() == nullptr) && (__newoff != off_type(0))) + return __error; + this->setg(this->eback(), this->eback() + __newoff, this->egptr()); + } + + if (__which & ios_base::out) { + if ((this->pptr() == nullptr) && (__newoff != off_type(0))) + return __error; + this->setp(this->pbase(), this->epptr()); + this->pbump(__newoff); + } + + return pos_type(__newoff); + } + + _LIBCPP_HIDE_FROM_ABI pos_type seekpos(pos_type __sp, + ios_base::openmode __which = ios_base::in | ios_base::out) override { + return seekoff(off_type(__sp), ios_base::beg, __which); + } + +private: + ios_base::openmode __mode_; // exposition only + std::span<_CharT> __buf_; // exposition only +}; + +template +void swap(basic_spanbuf<_CharT, _Traits>& __x, basic_spanbuf<_CharT, _Traits>& __y) { + __x.swap(__y); +} + +using spanbuf = basic_spanbuf; +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +using wspanbuf = basic_spanbuf; +# endif + +// Class template basic_ispanstream [ispanstream] + +template > +class basic_ispanstream : public basic_istream<_CharT, _Traits> { +public: + using char_type = _CharT; + using int_type = typename _Traits::int_type; + using pos_type = typename _Traits::pos_type; + using off_type = typename _Traits::off_type; + using traits_type = _Traits; + + // [ispanstream.cons], constructors + + explicit basic_ispanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::in) + : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), + __sb_(basic_spanbuf<_CharT, _Traits>(__s, __which | ios_base::in)) {} + + basic_ispanstream(const basic_ispanstream&) = delete; + + basic_ispanstream(basic_ispanstream&& __rhs) + : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { + basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); + } + + template + requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> + explicit basic_ispanstream(_ROSeq&& __s) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { + std::span __sp(std::forward<_ROSeq>(__s)); + this->span(std::span<_CharT>(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size()))); + } + + basic_ispanstream& operator=(const basic_ispanstream&) = delete; + + basic_ispanstream& operator=(basic_ispanstream&& __rhs) { + basic_ispanstream __tmp{std::move(__rhs)}; + this->swap(__tmp); + return *this; + } + + // [ispanstream.swap], swap + + void swap(basic_ispanstream& __rhs) { + basic_istream<_CharT, _Traits>::swap(__rhs); + __sb_.swap(__rhs.__sb_); + } + + // [ispanstream.members], member functions + + basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { + return const_cast*>(std::addressof(__sb_)); + } + + std::span span() const noexcept { return rdbuf()->span(); } + + void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } + + template + requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> + void span(_ROSeq&& __s) noexcept { + std::span __sp(std::forward<_ROSeq>(__s)); + this->span(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size())); + } + +private: + basic_spanbuf<_CharT, _Traits> __sb_; // exposition only +}; + +template +void swap(basic_ispanstream<_CharT, _Traits>& __x, basic_ispanstream<_CharT, _Traits>& __y) { + __x.swap(__y); +} + +using ispanstream = basic_ispanstream; +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +using wispanstream = basic_ispanstream; +# endif + +// Class template basic_ospanstream [ospanstream] + +template > +class basic_ospanstream : public basic_ostream<_CharT, _Traits> { +public: + using char_type = _CharT; + using int_type = typename _Traits::int_type; + using pos_type = typename _Traits::pos_type; + using off_type = typename _Traits::off_type; + using traits_type = _Traits; + + // [ospanstream.cons], constructors + + explicit basic_ospanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::out) + : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), + __sb_(basic_spanbuf<_CharT, _Traits>(__s, __which | ios_base::out)) {} + + basic_ospanstream(const basic_ospanstream&) = delete; + + basic_ospanstream(basic_ospanstream&& __rhs) : basic_ospanstream(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { + basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); + } + + basic_ospanstream& operator=(const basic_ospanstream&) = delete; + + basic_ospanstream& operator=(basic_ospanstream&& __rhs) { + basic_ospanstream __tmp{std::move(__rhs)}; + this->swap(__tmp); + return *this; + } + + // [ospanstream.swap], swap + + void swap(basic_ospanstream& __rhs) { + basic_ostream<_CharT, _Traits>::swap(__rhs); + __sb_.swap(__rhs.__sb_); + } + + // [ospanstream.members], member functions + + basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } + + std::span<_CharT> span() const noexcept { return __sb_.rdbuf()->span(); } + + void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } + +private: + basic_spanbuf<_CharT, _Traits> __sb_; // exposition only +}; + +template +void swap(basic_ospanstream<_CharT, _Traits>& __x, basic_ospanstream<_CharT, _Traits>& __y) { + __x.swap(__y); +} + +using ospanstream = basic_ospanstream; +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +using wospanstream = basic_ospanstream; +# endif + +template > +class basic_spanstream : public basic_iostream<_CharT, _Traits> { +public: + using char_type = _CharT; + using int_type = typename _Traits::int_type; + using pos_type = typename _Traits::pos_type; + using off_type = typename _Traits::off_type; + using traits_type = _Traits; + + // [spanstream.cons], constructors + + explicit basic_spanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::out | ios_base::in) + : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(basic_spanbuf<_CharT, _Traits>(__s, __which)) {} + + basic_spanstream(const basic_spanstream&) = delete; + + basic_spanstream(basic_spanstream&& __rhs) : basic_spanstream(std::move(__rhs)), __sb_(__rhs.__sb_) { + basic_iostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); + } + + basic_spanstream& operator=(const basic_spanstream&) = delete; + + basic_spanstream& operator=(basic_spanstream&& __rhs) { + basic_spanstream __tmp{std::move(__rhs)}; + this->swap(__tmp); + return *this; + } + + // [spanstream.swap], swap + + void swap(basic_spanstream& __rhs) { + basic_iostream<_CharT, _Traits>::swap(__rhs); + __sb_.swap(__rhs.__sb_); + } + + // [spanstream.members], members + + basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } + + std::span<_CharT> span() const noexcept { return rdbuf()->span(); } + + void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } + +private: + basic_spanbuf<_CharT, _Traits> __sb_; // exposition only +}; + +template +void swap(basic_spanstream<_CharT, _Traits>& __x, basic_spanstream<_CharT, _Traits>& __y) { + __x.swap(__y); +} + +using spanstream = basic_spanstream; +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +using wspanstream = basic_spanstream; +# endif + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +#endif + +#endif // _LIBCPP_SPANSTREAM diff --git a/libcxx/include/version b/libcxx/include/version index d98049bd57046..a83f7b36958c5 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -530,7 +530,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_ranges_to_container 202202L // # define __cpp_lib_ranges_zip 202110L // # define __cpp_lib_reference_from_temporary 202202L -// # define __cpp_lib_spanstream 202106L +# define __cpp_lib_spanstream 202106L // # define __cpp_lib_stacktrace 202011L # define __cpp_lib_stdatomic_h 202011L # define __cpp_lib_string_contains 202011L diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in index dd7385bf33a42..b4222ba307c2d 100644 --- a/libcxx/modules/std.compat.cppm.in +++ b/libcxx/modules/std.compat.cppm.in @@ -66,9 +66,6 @@ module; # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() -# if __has_include() -# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" -# endif // __has_include() # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index 984b18321923c..4e927f88722f0 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -100,7 +100,8 @@ module; #include #include #include -#include +# include +# include #include #include #include @@ -150,9 +151,6 @@ module; # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() -# if __has_include() -# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" -# endif // __has_include() # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/lit.local.cfg b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/lit.local.cfg new file mode 100644 index 0000000000000..2cb10010c4507 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/lit.local.cfg @@ -0,0 +1,3 @@ +# All non-trivial uses of iostreams require localization support +if "no-localization" in config.available_features: + config.unsupported = True diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..4a307014fa0f7 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// [ispanstream.general] + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp new file mode 100644 index 0000000000000..773efffd61a39 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_istream { +// public: +// using char_type = charT; +// using int_type = typename traits::int_type; +// using pos_type = typename traits::pos_type; +// using off_type = typename traits::off_type; +// using traits_type = traits; + +// using ispanstream = basic_ispanstream; +// using wispanstream = basic_ispanstream; + +#include +#include +#include + +#include "test_macros.h" + +// Types + +static_assert(std::is_base_of_v, std::ispanstream>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_base_of_v, std::wispanstream>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); +#endif + +// Copy properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); +#endif + diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/lit.local.cfg b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/lit.local.cfg new file mode 100644 index 0000000000000..2cb10010c4507 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/lit.local.cfg @@ -0,0 +1,3 @@ +# All non-trivial uses of iostreams require localization support +if "no-localization" in config.available_features: + config.unsupported = True diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..6f9497040a897 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// [ospanstream.general] + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp new file mode 100644 index 0000000000000..ab0cac0716840 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_ostream { +// public: +// using char_type = charT; +// using int_type = typename traits::int_type; +// using pos_type = typename traits::pos_type; +// using off_type = typename traits::off_type; +// using traits_type = traits; + +// using ospanstream = basic_ospanstream; +// using wospanstream = basic_ospanstream; + +#include +#include +#include + +#include "test_macros.h" + +// Types + +static_assert(std::is_base_of_v, std::ospanstream>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_base_of_v, std::wospanstream>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); +#endif + +// Copy properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); +#endif + diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp new file mode 100644 index 0000000000000..4675c0e5fc299 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// basic_spanbuf(); + +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +template > +void test() { + using SpanBuf = std::basic_spanbuf; + + static_assert(std::default_initializable); + + SpanBuf spBuf; + assert(spBuf.span().empty()); +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/lit.local.cfg b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/lit.local.cfg new file mode 100644 index 0000000000000..2cb10010c4507 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/lit.local.cfg @@ -0,0 +1,3 @@ +# All non-trivial uses of iostreams require localization support +if "no-localization" in config.available_features: + config.unsupported = True diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..fc746f4af7c76 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// [spanbuf.general] + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp new file mode 100644 index 0000000000000..4585147ea8d2e --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_streambuf { +// public: +// using char_type = charT; +// using int_type = typename traits::int_type; +// using pos_type = typename traits::pos_type; +// using off_type = typename traits::off_type; +// using traits_type = traits; + +// using spanbuf = basic_spanbufchar>; +// using wspanbuf = basic_spanbuf; + +#include +#include +#include + +#include "test_macros.h" + +// Types + +static_assert(std::is_base_of_v, std::spanbuf>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_base_of_v, std::wspanbuf>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); +#endif + +// Copy properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); +#endif + diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/lit.local.cfg b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/lit.local.cfg new file mode 100644 index 0000000000000..2cb10010c4507 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/lit.local.cfg @@ -0,0 +1,3 @@ +# All non-trivial uses of iostreams require localization support +if "no-localization" in config.available_features: + config.unsupported = True diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..8677bb6d0906d --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp @@ -0,0 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// [spanstream.general] + +int main(int, char**) { return 0; } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp new file mode 100644 index 0000000000000..4e90f259ccf48 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { +// public: +// using char_type = charT; +// using int_type = typename traits::int_type; +// using pos_type = typename traits::pos_type; +// using off_type = typename traits::off_type; +// using traits_type = traits; + +// using spanstream = basic_spanstream; +// using wspanstream = basic_spanstream; + +#include +#include +#include + +#include "test_macros.h" + +// Types + +static_assert(std::is_base_of_v, std::spanstream>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_base_of_v, std::wspanstream>); +static_assert(std::is_same_v); +static_assert(std::is_same_v::int_type>); +static_assert(std::is_same_v::pos_type>); +static_assert(std::is_same_v::off_type>); +static_assert(std::is_same_v>); +#endif + +// Copy properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_copy_assignable_v); +#endif + +// Move properties + +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::is_move_constructible_v); +static_assert(std::is_move_assignable_v); +#endif diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp new file mode 100644 index 0000000000000..8719352d4367e --- /dev/null +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_feature_test_macro_components.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test the feature test macros defined by + +/* Constant Value + __cpp_lib_spanstream 202106L [C++23] +*/ + +#include +#include "test_macros.h" + +#if TEST_STD_VER < 14 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 14 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 17 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 20 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 23 + +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" +# endif + +#elif TEST_STD_VER > 23 + +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" +# endif + +#endif // TEST_STD_VER > 23 + diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index fe175fd758726..744ee4e4d1036 100644 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -1297,7 +1297,6 @@ def add_version_header(tc): "name": "__cpp_lib_spanstream", "values": {"c++23": 202106}, "headers": ["spanstream"], - "unimplemented": True, }, { "name": "__cpp_lib_ssize", From a96a0a245408cc8424c755fc3f5c1e2b488bc6c9 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 28 Feb 2024 18:30:36 +0200 Subject: [PATCH 002/120] Added forward declarations to `` --- libcxx/include/CMakeLists.txt | 1 + libcxx/include/__fwd/spanstream.h | 48 +++++++++++++++++++++++++++++++ libcxx/include/iosfwd | 20 +++++++++++++ libcxx/include/spanstream | 15 +++++----- 4 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 libcxx/include/__fwd/spanstream.h diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 936963e89e97f..21ef9575b8803 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -455,6 +455,7 @@ set(files __fwd/queue.h __fwd/set.h __fwd/span.h + __fwd/spanstream.h __fwd/sstream.h __fwd/stack.h __fwd/streambuf.h diff --git a/libcxx/include/__fwd/spanstream.h b/libcxx/include/__fwd/spanstream.h new file mode 100644 index 0000000000000..2afeaaecf7fb4 --- /dev/null +++ b/libcxx/include/__fwd/spanstream.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_SPANSTREAM_H +#define _LIBCPP___FWD_SPANSTREAM_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +template > +class _LIBCPP_TEMPLATE_VIS basic_spanbuf; +template > +class _LIBCPP_TEMPLATE_VIS basic_ispanstream; +template > +class _LIBCPP_TEMPLATE_VIS basic_ospanstream; +template > +class _LIBCPP_TEMPLATE_VIS basic_spanstream; + +using spanbuf = basic_spanbuf; +using ispanstream = basic_ispanstream; +using ospanstream = basic_ospanstream; +using spanstream = basic_spanstream; + +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +using wspanbuf = basic_spanbuf; +using wispanstream = basic_ispanstream; +using wospanstream = basic_ospanstream; +using wspanstream = basic_spanstream; +# endif + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_SPANSTREAM_H diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd index 7f7c9417d3e70..99c0815726704 100644 --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -41,6 +41,15 @@ template , class Allocator = allo template , class Allocator = allocator > class basic_stringstream; + template> + class basic_spanbuf; // Since C++23 + template> + class basic_ispanstream; // Since C++23 + template> + class basic_ospanstream; // Since C++23 + template> + class basic_spanstream; // Since C++23 + template > class basic_filebuf; template > class basic_ifstream; template > class basic_ofstream; @@ -62,6 +71,11 @@ typedef basic_istringstream istringstream; typedef basic_ostringstream ostringstream; typedef basic_stringstream stringstream; +using spanbuf = basic_spanbuf; // Since C++23 +using ispanstream = basic_ispanstream; // Since C++23 +using ospanstream = basic_ospanstream; // Since C++23 +using spanstream = basic_spanstream; // Since C++23 + typedef basic_filebuf filebuf; typedef basic_ifstream ifstream; typedef basic_ofstream ofstream; @@ -77,6 +91,11 @@ typedef basic_istringstream wistringstream; typedef basic_ostringstream wostringstream; typedef basic_stringstream wstringstream; +using wspanbuf = basic_spanbuf; // Since C++23 +using wispanstream = basic_ispanstream; // Since C++23 +using wospanstream = basic_ospanstream; // Since C++23 +using wspanstream = basic_spanstream; // Since C++23 + typedef basic_filebuf wfilebuf; typedef basic_ifstream wifstream; typedef basic_ofstream wofstream; @@ -114,6 +133,7 @@ using wosyncstream = basic_osyncstream; // C++20 # include <__fwd/istream.h> # include <__fwd/memory.h> # include <__fwd/ostream.h> +# include <__fwd/spanstream.h> # include <__fwd/sstream.h> # include <__fwd/streambuf.h> # include <__fwd/string.h> diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index f25a04c2cb525..ffaba85ef252c 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -57,6 +57,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__availability> #include <__config> +#include <__fwd/spanstream.h> #include <__memory/addressof.h> #include <__ranges/concepts.h> #include <__utility/cmp.h> @@ -81,7 +82,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // Class template basic_spanbuf [spanbuf] -template > +template class _LIBCPP_TEMPLATE_VIS basic_spanbuf : public basic_streambuf<_CharT, _Traits> { public: using char_type = _CharT; @@ -223,8 +224,8 @@ using wspanbuf = basic_spanbuf; // Class template basic_ispanstream [ispanstream] -template > -class basic_ispanstream : public basic_istream<_CharT, _Traits> { +template +class _LIBCPP_TEMPLATE_VIS basic_ispanstream : public basic_istream<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; @@ -300,8 +301,8 @@ using wispanstream = basic_ispanstream; // Class template basic_ospanstream [ospanstream] -template > -class basic_ospanstream : public basic_ostream<_CharT, _Traits> { +template +class _LIBCPP_TEMPLATE_VIS basic_ospanstream : public basic_ostream<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; @@ -358,8 +359,8 @@ using ospanstream = basic_ospanstream; using wospanstream = basic_ospanstream; # endif -template > -class basic_spanstream : public basic_iostream<_CharT, _Traits> { +template +class _LIBCPP_TEMPLATE_VIS basic_spanstream : public basic_iostream<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; From 68f9a3aa4e8b547f92b71b340c7ecef56eb7d52d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 28 Feb 2024 19:01:08 +0200 Subject: [PATCH 003/120] Tests: updated `types.compile.pass` --- .../ispanstream/types.compile.pass.cpp | 67 +++++++++---------- .../ospanstream/types.compile.pass.cpp | 67 +++++++++---------- .../spanbuf/types.compile.pass.cpp | 67 +++++++++---------- .../spanstream/types.compile.pass.cpp | 66 +++++++++--------- 4 files changed, 132 insertions(+), 135 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index 773efffd61a39..9615d270116ee 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -27,53 +27,52 @@ #include #include +#include "constexpr_char_traits.h" #include "test_macros.h" -// Types +template > +void test() { + using SpStream = std::basic_ispanstream; -static_assert(std::is_base_of_v, std::ispanstream>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); + // Types -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_base_of_v, std::wispanstream>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); -#endif + static_assert(std::is_base_of_v, SpStream>); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); -// Copy properties + // Copy properties -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); -#endif + // Move properties -// Move properties + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + // Move properties + static_assert(std::is_move_constructible_v); + static_assert(std::is_move_assignable_v); +} + +void test() { + test(); + test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + test(); + test>(); #endif +} -// Move properties - -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +// Aliases +static_assert(std::is_base_of_v, std::ispanstream>); +static_assert(std::is_same_v, std::ispanstream>); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +static_assert(std::is_base_of_v, std::wispanstream>); +static_assert(std::is_same_v, std::wispanstream>); #endif - diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index ab0cac0716840..e5a9e574eb39f 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -27,53 +27,52 @@ #include #include +#include "constexpr_char_traits.h" #include "test_macros.h" -// Types +template > +void test() { + using SpStream = std::basic_ospanstream; -static_assert(std::is_base_of_v, std::ospanstream>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); + // Types -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_base_of_v, std::wospanstream>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); -#endif + static_assert(std::is_base_of_v, SpStream>); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); -// Copy properties + // Copy properties -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); -#endif + // Move properties -// Move properties + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + // Move properties + static_assert(std::is_move_constructible_v); + static_assert(std::is_move_assignable_v); +} + +void test() { + test(); + test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + test(); + test>(); #endif +} -// Move properties - -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +// Aliases +static_assert(std::is_base_of_v, std::ospanstream>); +static_assert(std::is_same_v, std::ospanstream>); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +static_assert(std::is_base_of_v, std::wospanstream>); +static_assert(std::is_same_v, std::wospanstream>); #endif - diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp index 4585147ea8d2e..a8cc07ed524ea 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp @@ -27,53 +27,52 @@ #include #include +#include "constexpr_char_traits.h" #include "test_macros.h" -// Types +template > +void test() { + using SpBuf = std::basic_spanbuf; -static_assert(std::is_base_of_v, std::spanbuf>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); + // Types -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_base_of_v, std::wspanbuf>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); -#endif + static_assert(std::is_base_of_v, SpBuf>); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); -// Copy properties + // Copy properties -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); -#endif + // Move properties -// Move properties + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + // Move properties + static_assert(std::is_move_constructible_v); + static_assert(std::is_move_assignable_v); +} + +void test() { + test(); + test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + test(); + test>(); #endif +} -// Move properties - -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +// Aliases +static_assert(std::is_base_of_v, std::spanbuf>); +static_assert(std::is_same_v, std::spanbuf>); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +static_assert(std::is_base_of_v, std::wspanbuf>); +static_assert(std::is_same_v, std::wspanbuf>); #endif - diff --git a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp index 4e90f259ccf48..5714834be2ce1 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp @@ -27,52 +27,52 @@ #include #include +#include "constexpr_char_traits.h" #include "test_macros.h" -// Types +template > +void test() { + using SpStream = std::basic_spanstream; -static_assert(std::is_base_of_v, std::spanstream>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); + // Types -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_base_of_v, std::wspanstream>); -static_assert(std::is_same_v); -static_assert(std::is_same_v::int_type>); -static_assert(std::is_same_v::pos_type>); -static_assert(std::is_same_v::off_type>); -static_assert(std::is_same_v>); -#endif + static_assert(std::is_base_of_v, SpStream>); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); -// Copy properties + // Copy properties -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); -#endif + // Move properties + + static_assert(!std::is_copy_constructible_v); + static_assert(!std::is_copy_assignable_v); -// Move properties + // Move properties -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + static_assert(std::is_move_constructible_v); + static_assert(std::is_move_assignable_v); +} +void test() { + test(); + test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); + test(); + test>(); #endif +} -// Move properties - -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +// Aliases +static_assert(std::is_base_of_v, std::spanstream>); +static_assert(std::is_same_v, std::spanstream>); #ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::is_move_constructible_v); -static_assert(std::is_move_assignable_v); +static_assert(std::is_base_of_v, std::wspanstream>); +static_assert(std::is_same_v, std::wspanstream>); #endif From 709c27b4a0d39fed0cbdad7edaa3ca9671969264 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 28 Feb 2024 19:38:58 +0200 Subject: [PATCH 004/120] Implementation: added `_LIBCPP_HIDE_FROM_ABI` --- libcxx/include/__fwd/spanstream.h | 8 ++-- libcxx/include/spanstream | 74 +++++++++++++++++-------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/libcxx/include/__fwd/spanstream.h b/libcxx/include/__fwd/spanstream.h index 2afeaaecf7fb4..f5ff2ad2c9cfc 100644 --- a/libcxx/include/__fwd/spanstream.h +++ b/libcxx/include/__fwd/spanstream.h @@ -20,13 +20,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 23 -template > +template > class _LIBCPP_TEMPLATE_VIS basic_spanbuf; -template > +template > class _LIBCPP_TEMPLATE_VIS basic_ispanstream; -template > +template > class _LIBCPP_TEMPLATE_VIS basic_ospanstream; -template > +template > class _LIBCPP_TEMPLATE_VIS basic_spanstream; using spanbuf = basic_spanbuf; diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index ffaba85ef252c..16bbf04d81c55 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -105,6 +105,7 @@ public: } basic_spanbuf(const basic_spanbuf&) = delete; + _LIBCPP_HIDE_FROM_ABI basic_spanbuf(basic_spanbuf&& __rhs) : basic_streambuf<_CharT, _Traits>{std::move(__rhs)}, __mode_{std::move(__rhs.__mode_)}, @@ -113,6 +114,7 @@ public: // [spanbuf.assign], assignment and swap basic_spanbuf& operator=(const basic_spanbuf&) = delete; + _LIBCPP_HIDE_FROM_ABI basic_spanbuf& operator=(basic_spanbuf&& __rhs) { basic_spanbuf __tmp{std::move(__rhs)}; this->swap(__tmp); @@ -213,13 +215,13 @@ private: }; template -void swap(basic_spanbuf<_CharT, _Traits>& __x, basic_spanbuf<_CharT, _Traits>& __y) { +_LIBCPP_HIDE_FROM_ABI void swap(basic_spanbuf<_CharT, _Traits>& __x, basic_spanbuf<_CharT, _Traits>& __y) { __x.swap(__y); } -using spanbuf = basic_spanbuf; +using std::spanbuf; # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wspanbuf = basic_spanbuf; +using std::wspanbuf; # endif // Class template basic_ispanstream [ispanstream] @@ -235,27 +237,28 @@ public: // [ispanstream.cons], constructors - explicit basic_ispanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::in) + _LIBCPP_HIDE_FROM_ABI explicit basic_ispanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::in) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(basic_spanbuf<_CharT, _Traits>(__s, __which | ios_base::in)) {} basic_ispanstream(const basic_ispanstream&) = delete; - basic_ispanstream(basic_ispanstream&& __rhs) + _LIBCPP_HIDE_FROM_ABI basic_ispanstream(basic_ispanstream&& __rhs) : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } template requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> - explicit basic_ispanstream(_ROSeq&& __s) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { + _LIBCPP_HIDE_FROM_ABI explicit basic_ispanstream(_ROSeq&& __s) + : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { std::span __sp(std::forward<_ROSeq>(__s)); this->span(std::span<_CharT>(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size()))); } basic_ispanstream& operator=(const basic_ispanstream&) = delete; - basic_ispanstream& operator=(basic_ispanstream&& __rhs) { + _LIBCPP_HIDE_FROM_ABI basic_ispanstream& operator=(basic_ispanstream&& __rhs) { basic_ispanstream __tmp{std::move(__rhs)}; this->swap(__tmp); return *this; @@ -263,24 +266,24 @@ public: // [ispanstream.swap], swap - void swap(basic_ispanstream& __rhs) { + _LIBCPP_HIDE_FROM_ABI void swap(basic_ispanstream& __rhs) { basic_istream<_CharT, _Traits>::swap(__rhs); __sb_.swap(__rhs.__sb_); } // [ispanstream.members], member functions - basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { + _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return const_cast*>(std::addressof(__sb_)); } - std::span span() const noexcept { return rdbuf()->span(); } + _LIBCPP_HIDE_FROM_ABI std::span span() const noexcept { return rdbuf()->span(); } - void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } + _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } template requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> - void span(_ROSeq&& __s) noexcept { + _LIBCPP_HIDE_FROM_ABI void span(_ROSeq&& __s) noexcept { std::span __sp(std::forward<_ROSeq>(__s)); this->span(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size())); } @@ -290,13 +293,13 @@ private: }; template -void swap(basic_ispanstream<_CharT, _Traits>& __x, basic_ispanstream<_CharT, _Traits>& __y) { +_LIBCPP_HIDE_FROM_ABI void swap(basic_ispanstream<_CharT, _Traits>& __x, basic_ispanstream<_CharT, _Traits>& __y) { __x.swap(__y); } -using ispanstream = basic_ispanstream; +using std::ispanstream; # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wispanstream = basic_ispanstream; +using std::wispanstream; # endif // Class template basic_ospanstream [ospanstream] @@ -312,19 +315,20 @@ public: // [ospanstream.cons], constructors - explicit basic_ospanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::out) + _LIBCPP_HIDE_FROM_ABI explicit basic_ospanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::out) : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(basic_spanbuf<_CharT, _Traits>(__s, __which | ios_base::out)) {} basic_ospanstream(const basic_ospanstream&) = delete; - basic_ospanstream(basic_ospanstream&& __rhs) : basic_ospanstream(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { + _LIBCPP_HIDE_FROM_ABI basic_ospanstream(basic_ospanstream&& __rhs) + : basic_ospanstream(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } basic_ospanstream& operator=(const basic_ospanstream&) = delete; - basic_ospanstream& operator=(basic_ospanstream&& __rhs) { + _LIBCPP_HIDE_FROM_ABI basic_ospanstream& operator=(basic_ospanstream&& __rhs) { basic_ospanstream __tmp{std::move(__rhs)}; this->swap(__tmp); return *this; @@ -332,31 +336,31 @@ public: // [ospanstream.swap], swap - void swap(basic_ospanstream& __rhs) { + _LIBCPP_HIDE_FROM_ABI void swap(basic_ospanstream& __rhs) { basic_ostream<_CharT, _Traits>::swap(__rhs); __sb_.swap(__rhs.__sb_); } // [ospanstream.members], member functions - basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } + _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } - std::span<_CharT> span() const noexcept { return __sb_.rdbuf()->span(); } + _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { return __sb_.rdbuf()->span(); } - void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } + _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } private: basic_spanbuf<_CharT, _Traits> __sb_; // exposition only }; template -void swap(basic_ospanstream<_CharT, _Traits>& __x, basic_ospanstream<_CharT, _Traits>& __y) { +_LIBCPP_HIDE_FROM_ABI void swap(basic_ospanstream<_CharT, _Traits>& __x, basic_ospanstream<_CharT, _Traits>& __y) { __x.swap(__y); } -using ospanstream = basic_ospanstream; +using std::ospanstream; # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wospanstream = basic_ospanstream; +using std::wospanstream; # endif template @@ -370,18 +374,20 @@ public: // [spanstream.cons], constructors - explicit basic_spanstream(std::span<_CharT> __s, ios_base::openmode __which = ios_base::out | ios_base::in) + _LIBCPP_HIDE_FROM_ABI explicit basic_spanstream(std::span<_CharT> __s, + ios_base::openmode __which = ios_base::out | ios_base::in) : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(basic_spanbuf<_CharT, _Traits>(__s, __which)) {} basic_spanstream(const basic_spanstream&) = delete; - basic_spanstream(basic_spanstream&& __rhs) : basic_spanstream(std::move(__rhs)), __sb_(__rhs.__sb_) { + _LIBCPP_HIDE_FROM_ABI basic_spanstream(basic_spanstream&& __rhs) + : basic_spanstream(std::move(__rhs)), __sb_(__rhs.__sb_) { basic_iostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } basic_spanstream& operator=(const basic_spanstream&) = delete; - basic_spanstream& operator=(basic_spanstream&& __rhs) { + _LIBCPP_HIDE_FROM_ABI basic_spanstream& operator=(basic_spanstream&& __rhs) { basic_spanstream __tmp{std::move(__rhs)}; this->swap(__tmp); return *this; @@ -396,24 +402,24 @@ public: // [spanstream.members], members - basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } + _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } - std::span<_CharT> span() const noexcept { return rdbuf()->span(); } + _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { return rdbuf()->span(); } - void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } + _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } private: basic_spanbuf<_CharT, _Traits> __sb_; // exposition only }; template -void swap(basic_spanstream<_CharT, _Traits>& __x, basic_spanstream<_CharT, _Traits>& __y) { +_LIBCPP_HIDE_FROM_ABI void swap(basic_spanstream<_CharT, _Traits>& __x, basic_spanstream<_CharT, _Traits>& __y) { __x.swap(__y); } -using spanstream = basic_spanstream; +using std::spanstream; # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wspanstream = basic_spanstream; +using std::wspanstream; # endif #endif // _LIBCPP_STD_VER >= 23 From 4cfdff435cc8189a52fc6f82b7118b4445e74cf0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 29 Feb 2024 11:05:55 +0200 Subject: [PATCH 005/120] Tests: `spanbuf` constructor tests --- .../ispanstream/types.compile.pass.cpp | 14 +- .../std/input.output/span.streams/macros.h | 18 ++ .../ospanstream/types.compile.pass.cpp | 14 +- .../spanbuf/spanbuf.cons/default.pass.cpp | 25 +- .../spanbuf/spanbuf.cons/mode.pass.cpp | 96 ++++++++ .../spanbuf/spanbuf.cons/move.pass.cpp | 224 ++++++++++++++++++ .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 155 ++++++++++++ .../spanbuf/types.compile.pass.cpp | 14 +- .../spanstream/types.compile.pass.cpp | 14 +- .../std/input.output/span.streams/types.h | 73 ++++++ 10 files changed, 615 insertions(+), 32 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/macros.h create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/types.h diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index 9615d270116ee..c566a3fce647d 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -30,18 +30,18 @@ #include "constexpr_char_traits.h" #include "test_macros.h" -template > +template > void test() { - using SpStream = std::basic_ispanstream; + using SpStream = std::basic_ispanstream; // Types - static_assert(std::is_base_of_v, SpStream>); + static_assert(std::is_base_of_v, SpStream>); static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); // Copy properties diff --git a/libcxx/test/std/input.output/span.streams/macros.h b/libcxx/test/std/input.output/span.streams/macros.h new file mode 100644 index 0000000000000..679686eaa41a8 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/macros.h @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_STD_INPUTOUTPUT_SPANSTREAMS_MACROS_H +#define TEST_STD_INPUTOUTPUT_SPANSTREAMS_MACROS_H + +#include "make_string.h" + +#define CS(S) MAKE_CSTRING(CharT, S) +#define ST(S, a) std::basic_string(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S), a) +#define SV(S) std::basic_string_view(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S)) + +#endif // TEST_STD_INPUTOUTPUT_SPANSTREAMS_MACROS_H diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index e5a9e574eb39f..595770aa5bd6b 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -30,18 +30,18 @@ #include "constexpr_char_traits.h" #include "test_macros.h" -template > +template > void test() { - using SpStream = std::basic_ospanstream; + using SpStream = std::basic_ospanstream; // Types - static_assert(std::is_base_of_v, SpStream>); + static_assert(std::is_base_of_v, SpStream>); static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); // Copy properties diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp index 4675c0e5fc299..4c6b1ae3080d9 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -21,19 +21,36 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" -template > -void test() { - using SpanBuf = std::basic_spanbuf; +void test_sfinae_with_nasty_char() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::default_initializable); +} + +template > +void test_sfinae() { + using SpBuf = std::basic_spanbuf; - static_assert(std::default_initializable); + static_assert(std::default_initializable); +} + +template > +void test() { + using SpanBuf = std::basic_spanbuf; SpanBuf spBuf; + assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); } int main(int, char**) { + test_sfinae_with_nasty_char(); + test_sfinae(); + test_sfinae>(); test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp new file mode 100644 index 0000000000000..5a497e5b3238c --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// explicit basic_spanbuf(ios_base::openmode which); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +#include "../../types.h" + +void test_sfinae_with_nasty_char() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::constructible_from); + static_assert(!test_convertible()); +} + +template > +void test_sfinae() { + using SpBuf = std::basic_spanbuf; + + // `Mode` + static_assert(std::constructible_from); + static_assert(!test_convertible()); + + // Non-mode + static_assert(!std::constructible_from); + static_assert(!test_convertible()); +} + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::default_initializable); + + // Mode: `in` + { + SpBuf spBuf(std::ios_base::in); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `out` + { + SpBuf spBuf(std::ios_base::out); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf spBuf(std::ios_base::out | std::ios_base::in | std::ios_base::binary); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } +} + +int main(int, char**) { + test_sfinae_with_nasty_char(); + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp new file mode 100644 index 0000000000000..cfc67b07ea303 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -0,0 +1,224 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// basic_spanbuf(basic_spanbuf&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +template +struct TestSpanBuf : std::basic_spanbuf { + using std::basic_spanbuf::basic_spanbuf; + + TestSpanBuf(std::basic_spanbuf&& rhs) : std::basic_spanbuf(std::move(rhs)) {} + + void check_postconditions(TestSpanBuf const& rhs_p) const { + assert(this->span().data() == rhs_p.span().data()); + assert(this->span().size() == rhs_p.span().size()); + assert(this->eback() == rhs_p.eback()); + assert(this->gptr() == rhs_p.gptr()); + assert(this->egptr() == rhs_p.egptr()); + assert(this->pbase() == rhs_p.pbase()); + assert(this->pptr() == rhs_p.pptr()); + assert(this->epptr() == rhs_p.epptr()); + assert(this->getloc() == rhs_p.getloc()); + } +}; + +void test_sfinae_with_nasty_char() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::move_constructible); +} + +template > +void test_sfinae() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::move_constructible); +} + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + { + // Empty `span` + { + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{std::ios_base::in}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `ios_base::out` + { + SpBuf rhsSpBuf{std::ios_base::out}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + } + + // Non-empty `span` + { + CharT arr[4]; + std::span sp{arr}; + + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `ios_base::out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + } + } + + // Check post-conditions + { + // Empty `span` + { + { + std::span sp; + TestSpanBuf rhsSpBuf(sp); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ios_base::in` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ios_base::out` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: multiple + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + } + + // Non-empty `span` + { + CharT arr[4]; + + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ios_base::in` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(!rhsSpBuf.span().empty()); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ios_base::out` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: multiple + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().empty()); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + } + } +} + +int main(int, char**) { + test_sfinae_with_nasty_char(); + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp new file mode 100644 index 0000000000000..fb58235d8c1fe --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -0,0 +1,155 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// explicit basic_spanbuf(std::span s, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +#include "../../macros.h" +#include "../../types.h" + +void test_sfinae_with_nasty_char() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible()); +} + +template > +void test_sfinae() { + using SpBuf = std::basic_spanbuf; + + // `Mode` + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible, std::ios_base::openmode>()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + static_assert(std::default_initializable); + + // Empty `span` + { + std::span sp{}; + + // Mode: `ios_base::in` + { + SpBuf spBuf(sp, std::ios_base::in); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::in); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `ios_base::out` + { + SpBuf spBuf(sp, std::ios_base::out); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::out); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + } + + // Non-empty `span` + { + CharT arr[4]; + std::span sp{arr}; + + // Mode: `ios_base::in` + { + SpBuf spBuf(sp, std::ios_base::in); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::in); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `ios_base::out` + { + SpBuf spBuf(sp, std::ios_base::out); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::out); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf spBuf(sp, std::ios_base::out | std::ios_base::in); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::out | std::ios_base::in | std::ios_base::binary); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + } +} + +int main(int, char**) { + test_sfinae_with_nasty_char(); + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#endif + + return 0; +} \ No newline at end of file diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp index a8cc07ed524ea..4c18422ebff28 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp @@ -30,18 +30,18 @@ #include "constexpr_char_traits.h" #include "test_macros.h" -template > +template > void test() { - using SpBuf = std::basic_spanbuf; + using SpBuf = std::basic_spanbuf; // Types - static_assert(std::is_base_of_v, SpBuf>); + static_assert(std::is_base_of_v, SpBuf>); static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); // Copy properties diff --git a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp index 5714834be2ce1..67d29cf041d9c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp @@ -30,18 +30,18 @@ #include "constexpr_char_traits.h" #include "test_macros.h" -template > +template > void test() { - using SpStream = std::basic_spanstream; + using SpStream = std::basic_spanstream; // Types - static_assert(std::is_base_of_v, SpStream>); + static_assert(std::is_base_of_v, SpStream>); static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); // Copy properties diff --git a/libcxx/test/std/input.output/span.streams/types.h b/libcxx/test/std/input.output/span.streams/types.h new file mode 100644 index 0000000000000..18788a56579dc --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/types.h @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H +#define TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H + +#include +#include + +#include "test_macros.h" + +// template > +// class ConstConvertibleStringView { +// public: +// explicit ConstConvertibleStringView(const CharT* cs) : cs_{cs} {} + +// operator std::basic_string_view() = delete; +// operator std::basic_string_view() const { return std::basic_string_view(cs_); } + +// private: +// const CharT* cs_; +// }; + +// static_assert(!std::constructible_from, ConstConvertibleStringView>); +// static_assert(!std::convertible_to, std::basic_string_view>); + +// static_assert(std::constructible_from, const ConstConvertibleStringView>); +// static_assert(std::convertible_to, std::basic_string_view>); + +// #ifndef TEST_HAS_NO_WIDE_CHARACTERS +// static_assert(!std::constructible_from, ConstConvertibleStringView>); +// static_assert(!std::convertible_to, std::basic_string_view>); + +// static_assert(std::constructible_from, const ConstConvertibleStringView>); +// static_assert(std::convertible_to, std::basic_string_view>); +// #endif + +// template > +// class NonConstConvertibleStringView { +// public: +// explicit NonConstConvertibleStringView(const CharT* cs) : cs_{cs} {} + +// operator std::basic_string_view() { return std::basic_string_view(cs_); } +// operator std::basic_string_view() const = delete; + +// private: +// const CharT* cs_; +// }; + +// static_assert(std::constructible_from, NonConstConvertibleStringView>); +// static_assert(std::convertible_to, std::basic_string_view>); + +// static_assert(!std::constructible_from, const NonConstConvertibleStringView>); +// static_assert(!std::convertible_to, std::basic_string_view>); + +// #ifndef TEST_HAS_NO_WIDE_CHARACTERS +// static_assert(std::constructible_from, NonConstConvertibleStringView>); +// static_assert(std::convertible_to, std::basic_string_view>); + +// static_assert(!std::constructible_from, const NonConstConvertibleStringView>); +// static_assert(!std::convertible_to, std::basic_string_view>); +// #endif + +struct SomeObject {}; + +struct NonMode {}; + +#endif // TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H From 505fef99c972a3a4a860ca5a5af0941bb08ec6c1 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 09:49:14 +0200 Subject: [PATCH 006/120] Tests: tweaks --- .../ospanstream/types.compile.pass.cpp | 11 +++--- .../spanbuf/spanbuf.cons/default.pass.cpp | 20 +--------- .../spanbuf/spanbuf.cons/mode.pass.cpp | 9 ++++- .../spanbuf/spanbuf.cons/move.pass.cpp | 24 ++++++++++-- .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 38 +++++++++++++++++-- .../spanbuf/types.compile.pass.cpp | 11 +++--- .../spanstream/types.compile.pass.cpp | 11 +++--- 7 files changed, 83 insertions(+), 41 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index 595770aa5bd6b..5374011f61cc2 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -28,12 +28,17 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > void test() { using SpStream = std::basic_ospanstream; + // Constructors + + static_assert(!std::is_default_constructible_v); + // Types static_assert(std::is_base_of_v, SpStream>); @@ -50,11 +55,6 @@ void test() { // Move properties - static_assert(!std::is_copy_constructible_v); - static_assert(!std::is_copy_assignable_v); - - // Move properties - static_assert(std::is_move_constructible_v); static_assert(std::is_move_assignable_v); } @@ -62,6 +62,7 @@ void test() { void test() { test(); test>(); + test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp index 4c6b1ae3080d9..a94551a96e000 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -24,33 +24,17 @@ #include "nasty_string.h" #include "test_macros.h" -void test_sfinae_with_nasty_char() { - using SpBuf = std::basic_spanbuf; - - static_assert(std::default_initializable); -} - -template > -void test_sfinae() { - using SpBuf = std::basic_spanbuf; - - static_assert(std::default_initializable); -} - template > void test() { - using SpanBuf = std::basic_spanbuf; + using SpBuf = std::basic_spanbuf; - SpanBuf spBuf; + SpBuf spBuf; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } int main(int, char**) { - test_sfinae_with_nasty_char(); - test_sfinae(); - test_sfinae>(); test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index 5a497e5b3238c..b452b6e80248e 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -33,15 +33,20 @@ void test_sfinae_with_nasty_char() { using SpBuf = std::basic_spanbuf; + // Mode static_assert(std::constructible_from); static_assert(!test_convertible()); + + // Non-mode + static_assert(!std::constructible_from); + static_assert(!test_convertible()); } template > void test_sfinae() { using SpBuf = std::basic_spanbuf; - // `Mode` + // Mode static_assert(std::constructible_from); static_assert(!test_convertible()); @@ -72,7 +77,7 @@ void test() { } // Mode: multiple { - SpBuf spBuf(std::ios_base::out | std::ios_base::in | std::ios_base::binary); + SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index cfc67b07ea303..b32f6703981af 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -32,7 +32,7 @@ template struct TestSpanBuf : std::basic_spanbuf { using std::basic_spanbuf::basic_spanbuf; - TestSpanBuf(std::basic_spanbuf&& rhs) : std::basic_spanbuf(std::move(rhs)) {} + TestSpanBuf(std::basic_spanbuf&& rhs_p) : std::basic_spanbuf(std::move(rhs_p)) {} void check_postconditions(TestSpanBuf const& rhs_p) const { assert(this->span().data() == rhs_p.span().data()); @@ -67,6 +67,14 @@ void test() { { // Empty `span` { + // Mode: default + { + SpBuf rhsSpBuf; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } // Mode: `ios_base::in` { SpBuf rhsSpBuf{std::ios_base::in}; @@ -98,6 +106,14 @@ void test() { CharT arr[4]; std::span sp{arr}; + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } // Mode: `ios_base::in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; @@ -129,6 +145,7 @@ void test() { { // Empty `span` { + // Mode: default { std::span sp; TestSpanBuf rhsSpBuf(sp); @@ -158,7 +175,7 @@ void test() { // Mode: multiple { std::span sp; - TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary); + TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); assert(rhsSpBuf.span().empty()); assert(spBuf.span().data() == nullptr); @@ -170,6 +187,7 @@ void test() { { CharT arr[4]; + // Mode: default { std::span sp{arr}; TestSpanBuf rhsSpBuf(sp); @@ -199,7 +217,7 @@ void test() { // Mode: multiple { std::span sp{arr}; - TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary); + TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); assert(rhsSpBuf.span().empty()); assert(spBuf.span().data() == arr); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index fb58235d8c1fe..ff600b92e5c02 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -36,15 +36,20 @@ void test_sfinae_with_nasty_char() { using SpBuf = std::basic_spanbuf; + // Mode static_assert(std::constructible_from, std::ios_base::openmode>); static_assert(!test_convertible()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible()); } template > void test_sfinae() { using SpBuf = std::basic_spanbuf; - // `Mode` + // Mode static_assert(std::constructible_from, std::ios_base::openmode>); static_assert(!test_convertible, std::ios_base::openmode>()); @@ -63,6 +68,13 @@ void test() { { std::span sp{}; + // Mode: default + { + SpBuf spBuf(sp); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } // Mode: `ios_base::in` { SpBuf spBuf(sp, std::ios_base::in); @@ -89,6 +101,19 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } + // Mode: multiple + { + SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } } // Non-empty `span` @@ -96,6 +121,13 @@ void test() { CharT arr[4]; std::span sp{arr}; + // Mode: default + { + SpBuf spBuf(sp); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } // Mode: `ios_base::in` { SpBuf spBuf(sp, std::ios_base::in); @@ -124,13 +156,13 @@ void test() { } // Mode: multiple { - SpBuf spBuf(sp, std::ios_base::out | std::ios_base::in); + SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == arr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::out | std::ios_base::in | std::ios_base::binary); + SpBuf spBuf(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == arr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp index 4c18422ebff28..dec47dbf7b8eb 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp @@ -28,12 +28,17 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > void test() { using SpBuf = std::basic_spanbuf; + // Constructors + + static_assert(std::is_default_constructible_v); + // Types static_assert(std::is_base_of_v, SpBuf>); @@ -50,11 +55,6 @@ void test() { // Move properties - static_assert(!std::is_copy_constructible_v); - static_assert(!std::is_copy_assignable_v); - - // Move properties - static_assert(std::is_move_constructible_v); static_assert(std::is_move_assignable_v); } @@ -62,6 +62,7 @@ void test() { void test() { test(); test>(); + test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp index 67d29cf041d9c..7c33c604237a3 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp @@ -28,12 +28,17 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > void test() { using SpStream = std::basic_spanstream; + // Constructors + + static_assert(!std::is_default_constructible_v); + // Types static_assert(std::is_base_of_v, SpStream>); @@ -50,11 +55,6 @@ void test() { // Move properties - static_assert(!std::is_copy_constructible_v); - static_assert(!std::is_copy_assignable_v); - - // Move properties - static_assert(std::is_move_constructible_v); static_assert(std::is_move_assignable_v); } @@ -62,6 +62,7 @@ void test() { void test() { test(); test>(); + test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); From a90b60b8638aa60081f55c540d11e00b4e6fcf05 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 09:49:44 +0200 Subject: [PATCH 007/120] Tests: `ispanstream` constructors - WIP --- .../ispanstream.cons/move.pass.cpp | 81 +++++++++++ .../ispanstream/ispanstream.cons/ros.pass.cpp | 60 ++++++++ .../ispanstream.cons/span.mode.pass.cpp | 136 ++++++++++++++++++ .../ispanstream/types.compile.pass.cpp | 11 +- 4 files changed, 283 insertions(+), 5 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp new file mode 100644 index 0000000000000..ce711deedc140 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// basic_ispanstream(basic_ispanstream&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream rhsSpStream{sp}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpStream rhsSpStream{sp, std::ios_base::in}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream rhsSpStream{sp, std::ios_base::out}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpStream{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp new file mode 100644 index 0000000000000..d4c9b2a765ac1 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// template explicit basic_ispanstream(ROS&& s); + +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +void test_sfinae_with_nasty_char() { + using SpStream = std::basic_ispanstream; + + // TODO: +} + +template > +void test_sfinae() { + using SpStream = std::basic_ispanstream; + + // TODO: +} + +template > +void test() { + using SpStream = std::basic_ispanstream; + + // TODO: +} + +int main(int, char**) { + test_sfinae_with_nasty_char(); + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp new file mode 100644 index 0000000000000..0938e35d0fb60 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -0,0 +1,136 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// explicit basic_ispanstream(std::span s, +// ios_base::openmode which = ios_base::in); + +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +#include "../../macros.h" +#include "../../types.h" + +void test_sfinae_with_nasty_char() { + using SpStream = std::basic_ispanstream; + + // Mode + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} + +template > +void test_sfinae() { + using SpStream = std::basic_ispanstream; + + // Mode + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible, std::ios_base::openmode>()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream sps(sp); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + { + SpStream sps(std::as_const(sp)); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpStream sps(sp, std::ios_base::in); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + { + SpStream sps(std::as_const(sp), std::ios_base::in); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream sps(sp, std::ios_base::out); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::out); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: multiple + { + SpStream sps(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } +} + +int main(int, char**) { + test_sfinae_with_nasty_char(); + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#endif + + return 0; +} \ No newline at end of file diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index c566a3fce647d..ddd15186b7c18 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -28,12 +28,17 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > void test() { using SpStream = std::basic_ispanstream; + // Constructors + + static_assert(!std::is_default_constructible_v); + // Types static_assert(std::is_base_of_v, SpStream>); @@ -50,11 +55,6 @@ void test() { // Move properties - static_assert(!std::is_copy_constructible_v); - static_assert(!std::is_copy_assignable_v); - - // Move properties - static_assert(std::is_move_constructible_v); static_assert(std::is_move_assignable_v); } @@ -62,6 +62,7 @@ void test() { void test() { test(); test>(); + test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); From 29bdc6a73657c265500d536eecba3d19e69860fc Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 10:52:23 +0200 Subject: [PATCH 008/120] Implementation: fixed module and forward declarations --- libcxx/modules/std/spanstream.inc | 4 ++-- libcxx/utils/generate_iwyu_mapping.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libcxx/modules/std/spanstream.inc b/libcxx/modules/std/spanstream.inc index e5b096e993307..f299bf02c25da 100644 --- a/libcxx/modules/std/spanstream.inc +++ b/libcxx/modules/std/spanstream.inc @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// export namespace std { -#if 0 +#if _LIBCPP_STD_VER >= 23 using std::basic_spanbuf; using std::swap; @@ -38,5 +38,5 @@ export namespace std { # if _LIBCPP_HAS_WIDE_CHARACTERS using std::wspanstream; # endif -#endif +#endif // _LIBCPP_STD_VER >= 23 } // namespace std diff --git a/libcxx/utils/generate_iwyu_mapping.py b/libcxx/utils/generate_iwyu_mapping.py index ab3e3f14e14d8..c03334076222c 100644 --- a/libcxx/utils/generate_iwyu_mapping.py +++ b/libcxx/utils/generate_iwyu_mapping.py @@ -47,7 +47,7 @@ def IWYU_mapping(header: str) -> typing.Optional[typing.List[str]]: return ["utility"] elif header == "__fwd/subrange.h": return ["ranges"] - elif re.match("__fwd/(fstream|ios|istream|ostream|sstream|streambuf)[.]h", header): + elif re.match("__fwd/(fstream|ios|istream|ostream|spanstream|sstream|streambuf)[.]h", header): return ["iosfwd"] # Handle remaining forward declaration headers elif re.match("__fwd/(.+)[.]h", header): From 94dd6550ff947ebbad125d8d38ae719757d66bd0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 10:56:25 +0200 Subject: [PATCH 009/120] Implementation: fixed python code formatting --- libcxx/utils/generate_iwyu_mapping.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcxx/utils/generate_iwyu_mapping.py b/libcxx/utils/generate_iwyu_mapping.py index c03334076222c..c92fecda3daf0 100644 --- a/libcxx/utils/generate_iwyu_mapping.py +++ b/libcxx/utils/generate_iwyu_mapping.py @@ -47,7 +47,9 @@ def IWYU_mapping(header: str) -> typing.Optional[typing.List[str]]: return ["utility"] elif header == "__fwd/subrange.h": return ["ranges"] - elif re.match("__fwd/(fstream|ios|istream|ostream|spanstream|sstream|streambuf)[.]h", header): + elif re.match( + "__fwd/(fstream|ios|istream|ostream|spanstream|sstream|streambuf)[.]h", header + ): return ["iosfwd"] # Handle remaining forward declaration headers elif re.match("__fwd/(.+)[.]h", header): From 1d1612ac7306e13fe78c2634f2f02857370a1b3d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 11:20:59 +0200 Subject: [PATCH 010/120] Implementation: updated transitive includes --- libcxx/test/libcxx/transitive_includes/cxx03.csv | 8 ++++++++ libcxx/test/libcxx/transitive_includes/cxx11.csv | 8 ++++++++ libcxx/test/libcxx/transitive_includes/cxx14.csv | 8 ++++++++ libcxx/test/libcxx/transitive_includes/cxx17.csv | 8 ++++++++ libcxx/test/libcxx/transitive_includes/cxx20.csv | 8 ++++++++ libcxx/test/libcxx/transitive_includes/cxx23.csv | 7 +++++++ libcxx/test/libcxx/transitive_includes/cxx26.csv | 7 +++++++ 7 files changed, 54 insertions(+) diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index c0031543e47bc..c556b25fa70f9 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -1922,6 +1922,14 @@ span utility span variant span vector span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream type_traits +spanstream version sstream algorithm sstream array sstream atomic diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index c0031543e47bc..c556b25fa70f9 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -1922,6 +1922,14 @@ span utility span variant span vector span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream type_traits +spanstream version sstream algorithm sstream array sstream atomic diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index c2eb5b44e8d7a..6a84538751fa0 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -1960,6 +1960,14 @@ span utility span variant span vector span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream type_traits +spanstream version sstream algorithm sstream array sstream atomic diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index 332cb62f35b5f..1f9ee0fff7897 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -1975,6 +1975,14 @@ span utility span variant span vector span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream type_traits +spanstream version sstream algorithm sstream array sstream atomic diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index 55c79acff5a8f..f9def06373084 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -1993,6 +1993,14 @@ span utility span variant span vector span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream type_traits +spanstream version sstream algorithm sstream array sstream atomic diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index cb23c7a98de1b..8bc14a6b9c86e 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -886,6 +886,13 @@ span initializer_list span limits span stdexcept span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream version sstream bitset sstream cctype sstream cerrno diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 5f906338f4b7c..bed716fd88efa 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -872,6 +872,13 @@ span initializer_list span limits span stdexcept span version +spanstream cstddef +spanstream initializer_list +spanstream iostream +spanstream limits +spanstream span +spanstream streambuf +spanstream version sstream bitset sstream cctype sstream cerrno From 9efdaa09b1588004a6ae436481f6975bd70ff622 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 11:45:01 +0200 Subject: [PATCH 011/120] Implementation: fix CI --- libcxx/include/spanstream | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 16bbf04d81c55..814fa9a6f00e2 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -56,6 +56,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__availability> +#include <__concepts/convertible_to.h> #include <__config> #include <__fwd/spanstream.h> #include <__memory/addressof.h> From 7373d2b47becaad1c81283f55007b6b707abad31 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 13:33:23 +0200 Subject: [PATCH 012/120] Implementation: try to fix CI --- .../ispanstream/ispanstream.cons/move.pass.cpp | 1 - .../ispanstream/ispanstream.cons/ros.pass.cpp | 4 ++++ .../ispanstream.cons/span.mode.pass.cpp | 4 ++++ .../ispanstream/types.compile.pass.cpp | 4 +++- .../ospanstream/types.compile.pass.cpp | 4 +++- .../spanbuf/spanbuf.cons/default.pass.cpp | 1 - .../spanbuf/spanbuf.cons/mode.pass.cpp | 4 ++++ .../spanbuf/spanbuf.cons/move.pass.cpp | 17 ----------------- .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 4 ++++ .../span.streams/spanbuf/types.compile.pass.cpp | 4 +++- .../spanstream/types.compile.pass.cpp | 4 +++- 11 files changed, 28 insertions(+), 23 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp index ce711deedc140..1b456a8a0ef38 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp @@ -24,7 +24,6 @@ #include #include "constexpr_char_traits.h" -#include "nasty_string.h" #include "test_convertible.h" #include "test_macros.h" diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp index d4c9b2a765ac1..421ba8ff10e16 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -25,11 +25,13 @@ #include "nasty_string.h" #include "test_macros.h" +#ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { using SpStream = std::basic_ispanstream; // TODO: } +#endif // TEST_HAS_NO_NASTY_STRING template > void test_sfinae() { @@ -46,7 +48,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING test_sfinae_with_nasty_char(); +#endif test_sfinae(); test_sfinae>(); test(); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp index 0938e35d0fb60..cd793210e2c06 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -33,6 +33,7 @@ #include "../../macros.h" #include "../../types.h" +#ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { using SpStream = std::basic_ispanstream; @@ -44,6 +45,7 @@ void test_sfinae_with_nasty_char() { static_assert(!std::constructible_from, const NonMode>); static_assert(!test_convertible, const NonMode>()); } +#endif // TEST_HAS_NO_NASTY_STRING template > void test_sfinae() { @@ -120,7 +122,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING test_sfinae_with_nasty_char(); +#endif test_sfinae(); test_sfinae>(); test(); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index ddd15186b7c18..9b492a9c59985 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -60,9 +60,11 @@ void test() { } void test() { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); - test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index 5374011f61cc2..71f76790d66fd 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -60,9 +60,11 @@ void test() { } void test() { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); - test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp index a94551a96e000..b76af127f4314 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -21,7 +21,6 @@ #include #include "constexpr_char_traits.h" -#include "nasty_string.h" #include "test_macros.h" template > diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index b452b6e80248e..eb8b29de9fbff 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -30,6 +30,7 @@ #include "../../types.h" +#ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { using SpBuf = std::basic_spanbuf; @@ -41,6 +42,7 @@ void test_sfinae_with_nasty_char() { static_assert(!std::constructible_from); static_assert(!test_convertible()); } +#endif // TEST_HAS_NO_NASTY_STRING template > void test_sfinae() { @@ -85,7 +87,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING test_sfinae_with_nasty_char(); +#endif test_sfinae(); test_sfinae>(); test(); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index b32f6703981af..1bab0f860d9f3 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -24,7 +24,6 @@ #include #include "constexpr_char_traits.h" -#include "nasty_string.h" #include "test_convertible.h" #include "test_macros.h" @@ -47,19 +46,6 @@ struct TestSpanBuf : std::basic_spanbuf { } }; -void test_sfinae_with_nasty_char() { - using SpBuf = std::basic_spanbuf; - - static_assert(std::move_constructible); -} - -template > -void test_sfinae() { - using SpBuf = std::basic_spanbuf; - - static_assert(std::move_constructible); -} - template > void test() { using SpBuf = std::basic_spanbuf; @@ -228,9 +214,6 @@ void test() { } int main(int, char**) { - test_sfinae_with_nasty_char(); - test_sfinae(); - test_sfinae>(); test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index ff600b92e5c02..fbcc8eeded259 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -33,6 +33,7 @@ #include "../../macros.h" #include "../../types.h" +#ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { using SpBuf = std::basic_spanbuf; @@ -44,6 +45,7 @@ void test_sfinae_with_nasty_char() { static_assert(!std::constructible_from, const NonMode>); static_assert(!test_convertible()); } +#endif // TEST_HAS_NO_NASTY_STRING template > void test_sfinae() { @@ -171,7 +173,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING test_sfinae_with_nasty_char(); +#endif test_sfinae(); test_sfinae>(); test(); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp index dec47dbf7b8eb..7ffbb9d24eab9 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp @@ -60,9 +60,11 @@ void test() { } void test() { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); - test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp index 7c33c604237a3..83f6b235ae913 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp @@ -60,9 +60,11 @@ void test() { } void test() { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); - test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); From 836b92f58891145ef11bb45b1dd8884d04055d65 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 14:47:23 +0200 Subject: [PATCH 013/120] Implementation: fixes --- libcxx/include/spanstream | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 814fa9a6f00e2..9f048a065c5c0 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -323,7 +323,7 @@ public: basic_ospanstream(const basic_ospanstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_ospanstream(basic_ospanstream&& __rhs) - : basic_ospanstream(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { + : basic_ostream(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } @@ -382,7 +382,7 @@ public: basic_spanstream(const basic_spanstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_spanstream(basic_spanstream&& __rhs) - : basic_spanstream(std::move(__rhs)), __sb_(__rhs.__sb_) { + : basic_iostream(std::move(__rhs)), __sb_(__rhs.__sb_) { basic_iostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } From 0bd187f221165c26f7e6bccf22a60503af7756f3 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 15:53:25 +0200 Subject: [PATCH 014/120] Implementation: fixes --- libcxx/include/spanstream | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 9f048a065c5c0..1cad46a2cd1f5 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -323,7 +323,7 @@ public: basic_ospanstream(const basic_ospanstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_ospanstream(basic_ospanstream&& __rhs) - : basic_ostream(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { + : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } @@ -382,7 +382,7 @@ public: basic_spanstream(const basic_spanstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_spanstream(basic_spanstream&& __rhs) - : basic_iostream(std::move(__rhs)), __sb_(__rhs.__sb_) { + : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(__rhs.__sb_) { basic_iostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } From bd24fd0fa819a97bc9d4423869089affbb8662d9 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 1 Mar 2024 16:35:45 +0200 Subject: [PATCH 015/120] Tests: `ospanstream` and `spanstream` constructors + fixes --- libcxx/include/spanstream | 14 +- .../ospanstream.cons/move.pass.cpp | 80 ++++++++++ .../ospanstream.cons/span.mode.pass.cpp | 140 ++++++++++++++++++ .../spanstream/spanstream.cons/move.pass.cpp | 80 ++++++++++ .../spanstream.cons/span.mode.pass.cpp | 140 ++++++++++++++++++ 5 files changed, 449 insertions(+), 5 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 1cad46a2cd1f5..6a3911a08a047 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -323,7 +323,7 @@ public: basic_ospanstream(const basic_ospanstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_ospanstream(basic_ospanstream&& __rhs) - : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { + : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } @@ -344,9 +344,11 @@ public: // [ospanstream.members], member functions - _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } + _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { + return const_cast*>(std::addressof(__sb_)); + } - _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { return __sb_.rdbuf()->span(); } + _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { return rdbuf()->span(); } _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } @@ -382,7 +384,7 @@ public: basic_spanstream(const basic_spanstream&) = delete; _LIBCPP_HIDE_FROM_ABI basic_spanstream(basic_spanstream&& __rhs) - : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(__rhs.__sb_) { + : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { basic_iostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); } @@ -403,7 +405,9 @@ public: // [spanstream.members], members - _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { return __sb_; } + _LIBCPP_HIDE_FROM_ABI basic_spanbuf<_CharT, _Traits>* rdbuf() const noexcept { + return const_cast*>(std::addressof(__sb_)); + } _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { return rdbuf()->span(); } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp new file mode 100644 index 0000000000000..895e07cdf7ecb --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// basic_ospanstream(basic_ospanstream&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream rhsSpStream{sp}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: `ios_base::in` + { + SpStream rhsSpStream{sp, std::ios_base::in}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode `ios_base::out` + { + SpStream rhsSpStream{sp, std::ios_base::out}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpStream{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp new file mode 100644 index 0000000000000..086ea7c765382 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// explicit basic_ospanstream(std::span s, +// ios_base::openmode which = ios_base::in); + +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +#include "../../macros.h" +#include "../../types.h" + +#ifndef TEST_HAS_NO_NASTY_STRING +void test_sfinae_with_nasty_char() { + using SpStream = std::basic_ospanstream; + + // Mode + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} +#endif // TEST_HAS_NO_NASTY_STRING + +template > +void test_sfinae() { + using SpStream = std::basic_ospanstream; + + // Mode + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible, std::ios_base::openmode>()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream sps(sp); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: `ios_base::in` + { + SpStream sps(sp, std::ios_base::in); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::in); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode `ios_base::out` + { + SpStream sps(sp, std::ios_base::out); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::out); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: multiple + { + SpStream sps(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test_sfinae_with_nasty_char(); +#endif + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#endif + + return 0; +} \ No newline at end of file diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp new file mode 100644 index 0000000000000..1a02487d07198 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// basic_spanstream(basic_spanstream&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_spanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream rhsSpStream{sp}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: `ios_base::in` + { + SpStream rhsSpStream{sp, std::ios_base::in}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream rhsSpStream{sp, std::ios_base::out}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpStream{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream sps(std::move(rhsSpStream)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp new file mode 100644 index 0000000000000..8fcc216b2ef6b --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// explicit basic_spanstream(std::span s, +// ios_base::openmode which = ios_base::in); + +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_convertible.h" +#include "test_macros.h" + +#include "../../macros.h" +#include "../../types.h" + +#ifndef TEST_HAS_NO_NASTY_STRING +void test_sfinae_with_nasty_char() { + using SpStream = std::basic_spanstream; + + // Mode + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} +#endif // TEST_HAS_NO_NASTY_STRING + +template > +void test_sfinae() { + using SpStream = std::basic_spanstream; + + // Mode + static_assert(std::constructible_from, std::ios_base::openmode>); + static_assert(!test_convertible, std::ios_base::openmode>()); + + // Non-mode + static_assert(!std::constructible_from, const NonMode>); + static_assert(!test_convertible, const NonMode>()); +} + +template > +void test() { + using SpStream = std::basic_spanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream sps(sp); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp)); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: `ios_base::in` + { + SpStream sps(sp, std::ios_base::in); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + { + SpStream sps(std::as_const(sp), std::ios_base::in); + assert(sps.span().data() == arr); + assert(!sps.span().empty()); + assert(sps.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream sps(sp, std::ios_base::out); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::out); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + // Mode: multiple + { + SpStream sps(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } + { + SpStream sps(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(sps.span().data() == arr); + assert(sps.span().empty()); + assert(sps.span().size() == 0); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test_sfinae_with_nasty_char(); +#endif + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); + test(); + test>(); +#endif + + return 0; +} \ No newline at end of file From 4bc5407735d1e4e3db1fab49544ed6d6867a9963 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 2 Mar 2024 08:26:39 +0200 Subject: [PATCH 016/120] Tests: `ispanstream` added assign and swap --- libcxx/include/spanstream | 45 ++++++---- .../ispanstream.assign/move.pass.cpp | 80 ++++++++++++++++++ .../ispanstream.assign/swap.pass.cpp | 83 +++++++++++++++++++ .../swap_nonmember.pass.cpp | 79 ++++++++++++++++++ .../ispanstream.cons/move.pass.cpp | 40 ++++----- .../ispanstream.cons/span.mode.pass.cpp | 64 +++++++------- .../ospanstream.cons/move.pass.cpp | 40 ++++----- .../ospanstream.cons/span.mode.pass.cpp | 64 +++++++------- .../spanstream/spanstream.cons/move.pass.cpp | 40 ++++----- .../spanstream.cons/span.mode.pass.cpp | 64 +++++++------- 10 files changed, 427 insertions(+), 172 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 6a3911a08a047..70e6faa4206fb 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -167,24 +167,37 @@ protected: if ((__which & ios_base::in) && (__which & ios_base::out) && (ios_base::cur == __way)) return __error; - off_type __baseoff = [this, __way, __which] { - switch (__way) { - case ios_base::beg: - return off_type(0); - - case ios_base::cur: - if (__which & ios_base::out) - return off_type(this->pptr() - this->pbase()); - return off_type(this->gptr() - this->eback()); - - case ios_base::end: - if ((__which & ios_base::out) && !(__which & ios_base::in)) - return off_type(this->pptr() - this->pbase()); - return off_type(__buf_.size()); - } - }(); + // Calculate __baseoff + + off_type __baseoff; + + switch (__way) { + case ios_base::beg: + __baseoff = off_type(0); + break; + + case ios_base::cur: + if (__which & ios_base::out) + __baseoff = off_type(this->pptr() - this->pbase()); + else + __baseoff = off_type(this->gptr() - this->eback()); + break; + + case ios_base::end: + if ((__which & ios_base::out) && !(__which & ios_base::in)) + __baseoff = off_type(this->pptr() - this->pbase()); + else + __baseoff = off_type(__buf_.size()); + break; + + default: + return __error; + }; + + // Calculate __newoff off_type __newoff; + if (__builtin_add_overflow(__baseoff, __off, &__newoff) || (__newoff < off_type(0)) || (std::cmp_greater(__newoff, __buf_.size()))) return __error; diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp new file mode 100644 index 0000000000000..117e2a6828e9d --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// basic_ispanstream& operator=(basic_ispanstream&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream rhsSpSt{sp}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp new file mode 100644 index 0000000000000..45fc6370a06d4 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_streambuf { + +// // [ispanstream.swap], swap +// void swap(basic_ispanstream& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream rhsSpSt{sp}; + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp new file mode 100644 index 0000000000000..ae54e40929745 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// void swap(basic_ispanstream& x, basic_ispanstream& y); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpStream rhsSpSt{sp}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp index 1b456a8a0ef38..2207b773bd9ce 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp @@ -36,35 +36,35 @@ void test() { // Mode: default { - SpStream rhsSpStream{sp}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream rhsSpSt{sp}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode: `ios_base::in` { - SpStream rhsSpStream{sp, std::ios_base::in}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode `ios_base::out` { - SpStream rhsSpStream{sp, std::ios_base::out}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream rhsSpStream{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp index cd793210e2c06..3502bbc1d676d 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -69,55 +69,55 @@ void test() { // Mode: default { - SpStream sps(sp); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream spSt(sp); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } { - SpStream sps(std::as_const(sp)); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream spSt(std::as_const(sp)); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode: `ios_base::in` { - SpStream sps(sp, std::ios_base::in); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream spSt(sp, std::ios_base::in); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } { - SpStream sps(std::as_const(sp), std::ios_base::in); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream spSt(std::as_const(sp), std::ios_base::in); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode `ios_base::out` { - SpStream sps(sp, std::ios_base::out); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::out); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::out); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::out); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream sps(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp index 895e07cdf7ecb..43354d6b8dfcb 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp @@ -36,35 +36,35 @@ void test() { // Mode: default { - SpStream rhsSpStream{sp}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: `ios_base::in` { - SpStream rhsSpStream{sp, std::ios_base::in}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode `ios_base::out` { - SpStream rhsSpStream{sp, std::ios_base::out}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream rhsSpStream{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp index 086ea7c765382..f353719875bc9 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp @@ -69,55 +69,55 @@ void test() { // Mode: default { - SpStream sps(sp); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: `ios_base::in` { - SpStream sps(sp, std::ios_base::in); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::in); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::in); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::in); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode `ios_base::out` { - SpStream sps(sp, std::ios_base::out); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::out); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::out); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::out); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream sps(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp index 1a02487d07198..73206597cd27d 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp @@ -36,35 +36,35 @@ void test() { // Mode: default { - SpStream rhsSpStream{sp}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: `ios_base::in` { - SpStream rhsSpStream{sp, std::ios_base::in}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode `ios_base::out` { - SpStream rhsSpStream{sp, std::ios_base::out}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream rhsSpStream{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream sps(std::move(rhsSpStream)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt(std::move(rhsSpSt)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp index 8fcc216b2ef6b..61a1a2530ad75 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp @@ -69,55 +69,55 @@ void test() { // Mode: default { - SpStream sps(sp); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp)); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp)); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: `ios_base::in` { - SpStream sps(sp, std::ios_base::in); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream spSt(sp, std::ios_base::in); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } { - SpStream sps(std::as_const(sp), std::ios_base::in); - assert(sps.span().data() == arr); - assert(!sps.span().empty()); - assert(sps.span().size() == 4); + SpStream spSt(std::as_const(sp), std::ios_base::in); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode `ios_base::out` { - SpStream sps(sp, std::ios_base::out); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::out); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::out); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::out); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream sps(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } { - SpStream sps(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(sps.span().data() == arr); - assert(sps.span().empty()); - assert(sps.span().size() == 0); + SpStream spSt(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } } From fd1c254a2c9985eca1469798f4c3df9567c82da4 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 3 Mar 2024 18:08:43 +0200 Subject: [PATCH 017/120] Tests: added `ReadonlySpan` type --- .../ispanstream/ispanstream.cons/ros.pass.cpp | 2 + .../std/input.output/span.streams/types.h | 230 +++++++++++++++--- 2 files changed, 193 insertions(+), 39 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp index 421ba8ff10e16..017cf24a89d7b 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -25,6 +25,8 @@ #include "nasty_string.h" #include "test_macros.h" +#include "../../types.h" + #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { using SpStream = std::basic_ispanstream; diff --git a/libcxx/test/std/input.output/span.streams/types.h b/libcxx/test/std/input.output/span.streams/types.h index 18788a56579dc..0d8eecd5f4db0 100644 --- a/libcxx/test/std/input.output/span.streams/types.h +++ b/libcxx/test/std/input.output/span.streams/types.h @@ -9,62 +9,214 @@ #ifndef TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H #define TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H -#include #include +#include +#include +#include #include "test_macros.h" -// template > -// class ConstConvertibleStringView { -// public: -// explicit ConstConvertibleStringView(const CharT* cs) : cs_{cs} {} +template +class ReadOnlySpan { + explicit ReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} -// operator std::basic_string_view() = delete; -// operator std::basic_string_view() const { return std::basic_string_view(cs_); } +public: + operator std::span() = delete; -// private: -// const CharT* cs_; -// }; + operator std::span() { return std::span{arr_}; } -// static_assert(!std::constructible_from, ConstConvertibleStringView>); -// static_assert(!std::convertible_to, std::basic_string_view>); + const CharT* begin() { return arr_; } + const CharT* end() { return arr_ + N; } -// static_assert(std::constructible_from, const ConstConvertibleStringView>); -// static_assert(std::convertible_to, std::basic_string_view>); +private: + CharT* arr_; +}; -// #ifndef TEST_HAS_NO_WIDE_CHARACTERS -// static_assert(!std::constructible_from, ConstConvertibleStringView>); -// static_assert(!std::convertible_to, std::basic_string_view>); +template +inline constexpr bool std::ranges::enable_borrowed_range> = true; -// static_assert(std::constructible_from, const ConstConvertibleStringView>); -// static_assert(std::convertible_to, std::basic_string_view>); -// #endif +static_assert(std::ranges::borrowed_range>); -// template > -// class NonConstConvertibleStringView { -// public: -// explicit NonConstConvertibleStringView(const CharT* cs) : cs_{cs} {} +static_assert(!std::constructible_from, ReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); -// operator std::basic_string_view() { return std::basic_string_view(cs_); } -// operator std::basic_string_view() const = delete; +static_assert(!std::constructible_from, const ReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); -// private: -// const CharT* cs_; -// }; +static_assert(std::constructible_from, ReadOnlySpan>); +static_assert(std::convertible_to, std::span>); -// static_assert(std::constructible_from, NonConstConvertibleStringView>); -// static_assert(std::convertible_to, std::basic_string_view>); +static_assert(!std::constructible_from, const ReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); -// static_assert(!std::constructible_from, const NonConstConvertibleStringView>); -// static_assert(!std::convertible_to, std::basic_string_view>); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS -// #ifndef TEST_HAS_NO_WIDE_CHARACTERS -// static_assert(std::constructible_from, NonConstConvertibleStringView>); -// static_assert(std::convertible_to, std::basic_string_view>); +static_assert(std::ranges::borrowed_range>); -// static_assert(!std::constructible_from, const NonConstConvertibleStringView>); -// static_assert(!std::convertible_to, std::basic_string_view>); -// #endif +static_assert(!std::constructible_from, ReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const ReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, ReadOnlySpan>); +static_assert(std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const ReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); +#endif + +template +class NonReadOnlySpan { + explicit NonReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} + +public: + operator std::span() { return std::span{arr_}; } + + operator std::span() = delete; + + CharT* begin() { return arr_; } + CharT* end() { return arr_ + N; } + +private: + CharT* arr_; +}; + +template +inline constexpr bool std::ranges::enable_borrowed_range> = true; + +static_assert(std::ranges::borrowed_range>); + +static_assert(std::constructible_from, NonReadOnlySpan>); +static_assert(std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, NonReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::ranges::borrowed_range>); + +static_assert(std::constructible_from, NonReadOnlySpan>); +static_assert(std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, NonReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); +#endif + +template +class ConstConvertibleReadOnlySpan { + explicit ConstConvertibleReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} + +public: + operator std::span() = delete; + operator std::span() const = delete; + + operator std::span() = delete; + operator std::span() const { return std::span{arr_}; } + + const CharT* begin() { return arr_; } + const CharT* end() { return arr_ + N; } + +private: + CharT* arr_; +}; + +template +inline constexpr bool std::ranges::enable_borrowed_range> = true; + +static_assert(std::ranges::borrowed_range>); + +static_assert(!std::constructible_from, ConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const ConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, ConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, const ConstConvertibleReadOnlySpan>); +static_assert(std::convertible_to, std::span>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + +static_assert(std::ranges::borrowed_range>); + +static_assert(!std::constructible_from, ConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const ConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, ConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, const ConstConvertibleReadOnlySpan>); +static_assert(std::convertible_to, std::span>); +#endif + +template +class NonConstConvertibleReadOnlySpan { + explicit NonConstConvertibleReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} + +public: + operator std::span() = delete; + operator std::span() const = delete; + + operator std::span() { return std::span{arr_}; } + operator std::span() const = delete; + + const CharT* begin() { return arr_; } + const CharT* end() { return arr_ + N; } + +private: + CharT* arr_; +}; + +template +inline constexpr bool std::ranges::enable_borrowed_range> = true; + +static_assert(std::ranges::borrowed_range>); + +static_assert(!std::constructible_from, NonConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, NonConstConvertibleReadOnlySpan>); +static_assert(std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +static_assert(std::ranges::borrowed_range>); + +static_assert(!std::constructible_from, NonConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); + +static_assert(std::constructible_from, NonConstConvertibleReadOnlySpan>); +static_assert(std::convertible_to, std::span>); + +static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); +static_assert(!std::convertible_to, std::span>); +#endif struct SomeObject {}; From bf1252717b5387522909f6ef8a330a162c214df6 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 4 Mar 2024 07:42:41 +0200 Subject: [PATCH 018/120] Tests: WIP `ROS` constructor --- libcxx/include/spanstream | 7 +++ .../{macros.h => helper_macros.h} | 0 .../span.streams/{types.h => helper_types.h} | 21 +++++-- .../ispanstream/ispanstream.cons/ros.pass.cpp | 62 +++++++++++++++++-- .../ispanstream.cons/span.mode.pass.cpp | 4 +- .../input.output/span.streams/lit.local.cfg | 3 + .../ospanstream.cons/span.mode.pass.cpp | 4 +- .../spanbuf/spanbuf.cons/mode.pass.cpp | 2 +- .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 4 +- .../spanstream.cons/span.mode.pass.cpp | 4 +- 10 files changed, 93 insertions(+), 18 deletions(-) rename libcxx/test/std/input.output/span.streams/{macros.h => helper_macros.h} (100%) rename libcxx/test/std/input.output/span.streams/{types.h => helper_types.h} (96%) create mode 100644 libcxx/test/std/input.output/span.streams/lit.local.cfg diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 70e6faa4206fb..14fd39d93e991 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -66,6 +66,7 @@ #include <__utility/move.h> #include <__utility/swap.h> #include +#include #include #include #include @@ -266,8 +267,14 @@ public: requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> _LIBCPP_HIDE_FROM_ABI explicit basic_ispanstream(_ROSeq&& __s) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { + std::println(stderr, "ispanstream"); std::span __sp(std::forward<_ROSeq>(__s)); + std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); + std::println(stderr, "span data {} {}", __sp.empty(), __sp.size()); + std::println(stderr, "ispanstream 2"); this->span(std::span<_CharT>(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size()))); + std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); + std::println(stderr, "ispanstream 3"); } basic_ispanstream& operator=(const basic_ispanstream&) = delete; diff --git a/libcxx/test/std/input.output/span.streams/macros.h b/libcxx/test/std/input.output/span.streams/helper_macros.h similarity index 100% rename from libcxx/test/std/input.output/span.streams/macros.h rename to libcxx/test/std/input.output/span.streams/helper_macros.h diff --git a/libcxx/test/std/input.output/span.streams/types.h b/libcxx/test/std/input.output/span.streams/helper_types.h similarity index 96% rename from libcxx/test/std/input.output/span.streams/types.h rename to libcxx/test/std/input.output/span.streams/helper_types.h index 0d8eecd5f4db0..81fb2c7557714 100644 --- a/libcxx/test/std/input.output/span.streams/types.h +++ b/libcxx/test/std/input.output/span.streams/helper_types.h @@ -16,17 +16,28 @@ #include "test_macros.h" +#include + template class ReadOnlySpan { +public: explicit ReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} -public: operator std::span() = delete; - operator std::span() { return std::span{arr_}; } + operator std::span() { + std::println(stderr, "----> ROspan"); + return std::span{arr_}; + } - const CharT* begin() { return arr_; } - const CharT* end() { return arr_ + N; } + const CharT* begin() { + std::println(stderr, "----> ROspan begin"); + return arr_; + } + const CharT* end() { + std::println(stderr, "----> ROspan end"); + return arr_ + N; + } private: CharT* arr_; @@ -68,9 +79,9 @@ static_assert(!std::convertible_to, std::span class NonReadOnlySpan { +public: explicit NonReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} -public: operator std::span() { return std::span{arr_}; } operator std::span() = delete; diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp index 017cf24a89d7b..7a4f0f422404f 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -19,27 +19,60 @@ // template explicit basic_ispanstream(ROS&& s); #include +#include #include #include "constexpr_char_traits.h" #include "nasty_string.h" +#include "test_convertible.h" #include "test_macros.h" -#include "../../types.h" +#include "../../helper_types.h" #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { using SpStream = std::basic_ispanstream; - // TODO: + // Non-const convertible + static_assert(std::constructible_from>); + static_assert(!test_convertible>()); + + // Const convertible + static_assert(!std::constructible_from>); + static_assert(!test_convertible>()); + + // Non-const non-convertible + static_assert(std::constructible_from>); + static_assert(!test_convertible>()); + + // Const non-convertible + static_assert(!std::constructible_from>); + static_assert(!test_convertible>()); } #endif // TEST_HAS_NO_NASTY_STRING template > void test_sfinae() { - using SpStream = std::basic_ispanstream; + using SpStream = + std::conditional_t, + std::basic_ispanstream, + std::basic_ispanstream>; - // TODO: + // Non-const convertible + static_assert(std::constructible_from>); + static_assert(!test_convertible>()); + + // Const convertible + static_assert(!std::constructible_from>); + static_assert(!test_convertible>()); + + // Non-const non-convertible + static_assert(std::constructible_from>); + static_assert(!test_convertible>()); + + // Const non-convertible + static_assert(!std::constructible_from>); + static_assert(!test_convertible>()); } template > @@ -47,10 +80,31 @@ void test() { using SpStream = std::basic_ispanstream; // TODO: + CharT arr[4]; + ReadOnlySpan ros{arr}; + + { + SpStream spSt(ros); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + + CharT arr1[6]; + ReadOnlySpan ros2{arr1}; + + { + SpStream spSt(ros2); + assert(spSt.span().data() == arr); + assert(spSt.span().data() == arr1); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } } int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING + // test_sfinae(); test_sfinae_with_nasty_char(); #endif test_sfinae(); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp index 3502bbc1d676d..3527d197e7cdf 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -30,8 +30,8 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../macros.h" -#include "../../types.h" +#include "../../helper_macros.h" +#include "../../helper_types.h" #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { diff --git a/libcxx/test/std/input.output/span.streams/lit.local.cfg b/libcxx/test/std/input.output/span.streams/lit.local.cfg new file mode 100644 index 0000000000000..2cb10010c4507 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/lit.local.cfg @@ -0,0 +1,3 @@ +# All non-trivial uses of iostreams require localization support +if "no-localization" in config.available_features: + config.unsupported = True diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp index f353719875bc9..e036a0be4a48b 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp @@ -30,8 +30,8 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../macros.h" -#include "../../types.h" +#include "../../helper_macros.h" +#include "../../helper_types.h" #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index eb8b29de9fbff..d040f0beb92a5 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -28,7 +28,7 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../types.h" +#include "../../helper_types.h" #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index fbcc8eeded259..45985aed49c61 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -30,8 +30,8 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../macros.h" -#include "../../types.h" +#include "../../helper_macros.h" +#include "../../helper_types.h" #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp index 61a1a2530ad75..2423c92fda9f8 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp @@ -30,8 +30,8 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../macros.h" -#include "../../types.h" +#include "../../helper_macros.h" +#include "../../helper_types.h" #ifndef TEST_HAS_NO_NASTY_STRING void test_sfinae_with_nasty_char() { From a1c51e6a949042f72d75934b61d3c2a41e881ea8 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 4 Mar 2024 07:47:34 +0200 Subject: [PATCH 019/120] Tests: WIP retry CI --- libcxx/include/spanstream | 14 +-- .../input.output/span.streams/helper_types.h | 111 +----------------- .../ispanstream/ispanstream.cons/ros.pass.cpp | 27 +---- 3 files changed, 13 insertions(+), 139 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 14fd39d93e991..c735baaae93d9 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -66,7 +66,7 @@ #include <__utility/move.h> #include <__utility/swap.h> #include -#include +// #include #include #include #include @@ -267,14 +267,14 @@ public: requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> _LIBCPP_HIDE_FROM_ABI explicit basic_ispanstream(_ROSeq&& __s) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { - std::println(stderr, "ispanstream"); + // std::println(stderr, "ispanstream"); std::span __sp(std::forward<_ROSeq>(__s)); - std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); - std::println(stderr, "span data {} {}", __sp.empty(), __sp.size()); - std::println(stderr, "ispanstream 2"); + // std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); + // std::println(stderr, "span data {} {}", __sp.empty(), __sp.size()); + // std::println(stderr, "ispanstream 2"); this->span(std::span<_CharT>(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size()))); - std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); - std::println(stderr, "ispanstream 3"); + // std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); + // std::println(stderr, "ispanstream 3"); } basic_ispanstream& operator=(const basic_ispanstream&) = delete; diff --git a/libcxx/test/std/input.output/span.streams/helper_types.h b/libcxx/test/std/input.output/span.streams/helper_types.h index 81fb2c7557714..7f67432f9f880 100644 --- a/libcxx/test/std/input.output/span.streams/helper_types.h +++ b/libcxx/test/std/input.output/span.streams/helper_types.h @@ -16,7 +16,7 @@ #include "test_macros.h" -#include +// #include template class ReadOnlySpan { @@ -26,16 +26,16 @@ class ReadOnlySpan { operator std::span() = delete; operator std::span() { - std::println(stderr, "----> ROspan"); + // std::println(stderr, "----> ROspan"); return std::span{arr_}; } const CharT* begin() { - std::println(stderr, "----> ROspan begin"); + // std::println(stderr, "----> ROspan begin"); return arr_; } const CharT* end() { - std::println(stderr, "----> ROspan end"); + // std::println(stderr, "----> ROspan end"); return arr_ + N; } @@ -126,109 +126,6 @@ static_assert(!std::constructible_from, const NonReadOn static_assert(!std::convertible_to, std::span>); #endif -template -class ConstConvertibleReadOnlySpan { - explicit ConstConvertibleReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} - -public: - operator std::span() = delete; - operator std::span() const = delete; - - operator std::span() = delete; - operator std::span() const { return std::span{arr_}; } - - const CharT* begin() { return arr_; } - const CharT* end() { return arr_ + N; } - -private: - CharT* arr_; -}; - -template -inline constexpr bool std::ranges::enable_borrowed_range> = true; - -static_assert(std::ranges::borrowed_range>); - -static_assert(!std::constructible_from, ConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(!std::constructible_from, const ConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(std::constructible_from, ConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(std::constructible_from, const ConstConvertibleReadOnlySpan>); -static_assert(std::convertible_to, std::span>); - -#ifndef TEST_HAS_NO_WIDE_CHARACTERS - -static_assert(std::ranges::borrowed_range>); - -static_assert(!std::constructible_from, ConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(!std::constructible_from, const ConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(std::constructible_from, ConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(std::constructible_from, const ConstConvertibleReadOnlySpan>); -static_assert(std::convertible_to, std::span>); -#endif - -template -class NonConstConvertibleReadOnlySpan { - explicit NonConstConvertibleReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} - -public: - operator std::span() = delete; - operator std::span() const = delete; - - operator std::span() { return std::span{arr_}; } - operator std::span() const = delete; - - const CharT* begin() { return arr_; } - const CharT* end() { return arr_ + N; } - -private: - CharT* arr_; -}; - -template -inline constexpr bool std::ranges::enable_borrowed_range> = true; - -static_assert(std::ranges::borrowed_range>); - -static_assert(!std::constructible_from, NonConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(std::constructible_from, NonConstConvertibleReadOnlySpan>); -static_assert(std::convertible_to, std::span>); - -static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -#ifndef TEST_HAS_NO_WIDE_CHARACTERS -static_assert(std::ranges::borrowed_range>); - -static_assert(!std::constructible_from, NonConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); - -static_assert(std::constructible_from, NonConstConvertibleReadOnlySpan>); -static_assert(std::convertible_to, std::span>); - -static_assert(!std::constructible_from, const NonConstConvertibleReadOnlySpan>); -static_assert(!std::convertible_to, std::span>); -#endif - struct SomeObject {}; struct NonMode {}; diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp index 7a4f0f422404f..6425b6ed94e49 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -29,28 +29,6 @@ #include "../../helper_types.h" -#ifndef TEST_HAS_NO_NASTY_STRING -void test_sfinae_with_nasty_char() { - using SpStream = std::basic_ispanstream; - - // Non-const convertible - static_assert(std::constructible_from>); - static_assert(!test_convertible>()); - - // Const convertible - static_assert(!std::constructible_from>); - static_assert(!test_convertible>()); - - // Non-const non-convertible - static_assert(std::constructible_from>); - static_assert(!test_convertible>()); - - // Const non-convertible - static_assert(!std::constructible_from>); - static_assert(!test_convertible>()); -} -#endif // TEST_HAS_NO_NASTY_STRING - template > void test_sfinae() { using SpStream = @@ -95,7 +73,7 @@ void test() { { SpStream spSt(ros2); - assert(spSt.span().data() == arr); + assert(spSt.span().data() != arr); assert(spSt.span().data() == arr1); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -104,8 +82,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - // test_sfinae(); - test_sfinae_with_nasty_char(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); From 6283a369362029665ae5d4f06e6562156a867b8e Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 09:50:42 +0200 Subject: [PATCH 020/120] Tests: Try to fix CI --- .../span.streams/ispanstream/ispanstream.cons/ros.pass.cpp | 4 ++++ libcxx/utils/generate_feature_test_macro_components.py | 1 + 2 files changed, 5 insertions(+) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp index 6425b6ed94e49..b2cae9b9f54ce 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -32,9 +32,13 @@ template > void test_sfinae() { using SpStream = +#ifndef TEST_HAS_NO_NASTY_STRING std::conditional_t, std::basic_ispanstream, std::basic_ispanstream>; +#else + std::basic_ispanstream; +#endif // Non-const convertible static_assert(std::constructible_from>); diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 744ee4e4d1036..bf9508e36410a 100644 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -1514,6 +1514,7 @@ def add_version_header(tc): "regex": ["UNSUPPORTED: no-localization"], "semaphore": ["UNSUPPORTED: no-threads"], "shared_mutex": ["UNSUPPORTED: no-threads"], + "spanstream": ["UNSUPPORTED: no-localization"], "sstream": ["UNSUPPORTED: no-localization"], "syncstream": ["UNSUPPORTED: no-localization"], "stdatomic.h": ["UNSUPPORTED: no-threads"], From d5bbf3f54895b3b01a1b59aeb59f35eef8f7801a Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 10:29:11 +0200 Subject: [PATCH 021/120] Tests: updated generated tests --- .../support.limits.general/spanstream.version.compile.pass.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index 8719352d4367e..53c528e320a87 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -11,6 +11,8 @@ // // clang-format off +// UNSUPPORTED: no-localization + // // Test the feature test macros defined by From 2eb5e6e7fce25b86ec570ae6afd3a6cea1e4b76a Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 17:13:47 +0200 Subject: [PATCH 022/120] Tests: WIP --- .../ispanstream.cons/span.mode.pass.cpp | 2 +- .../ospanstream.cons/span.mode.pass.cpp | 27 +++++++------------ .../spanbuf/spanbuf.cons/mode.pass.cpp | 25 +++++++---------- .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 2 +- .../spanstream.cons/span.mode.pass.cpp | 13 ++++++--- 5 files changed, 31 insertions(+), 38 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp index 3527d197e7cdf..a04cc578153b2 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -137,4 +137,4 @@ int main(int, char**) { #endif return 0; -} \ No newline at end of file +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp index e036a0be4a48b..bf619e8f18f7e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp @@ -33,23 +33,16 @@ #include "../../helper_macros.h" #include "../../helper_types.h" -#ifndef TEST_HAS_NO_NASTY_STRING -void test_sfinae_with_nasty_char() { - using SpStream = std::basic_ospanstream; - - // Mode - static_assert(std::constructible_from, std::ios_base::openmode>); - static_assert(!test_convertible()); - - // Non-mode - static_assert(!std::constructible_from, const NonMode>); - static_assert(!test_convertible, const NonMode>()); -} -#endif // TEST_HAS_NO_NASTY_STRING - template > void test_sfinae() { - using SpStream = std::basic_ospanstream; + using SpStream = +#ifndef TEST_HAS_NO_NASTY_STRING + std::conditional_t, + std::basic_ispanstream, + std::basic_ispanstream>; +#else + std::basic_ispanstream; +#endif // Mode static_assert(std::constructible_from, std::ios_base::openmode>); @@ -123,7 +116,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae_with_nasty_char(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); @@ -137,4 +130,4 @@ int main(int, char**) { #endif return 0; -} \ No newline at end of file +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index d040f0beb92a5..f4d7667ca8327 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -30,23 +30,16 @@ #include "../../helper_types.h" -#ifndef TEST_HAS_NO_NASTY_STRING -void test_sfinae_with_nasty_char() { - using SpBuf = std::basic_spanbuf; - - // Mode - static_assert(std::constructible_from); - static_assert(!test_convertible()); - - // Non-mode - static_assert(!std::constructible_from); - static_assert(!test_convertible()); -} -#endif // TEST_HAS_NO_NASTY_STRING - template > void test_sfinae() { - using SpBuf = std::basic_spanbuf; + using SpStream = +#ifndef TEST_HAS_NO_NASTY_STRING + std::conditional_t, + std::basic_ispanstream, + std::basic_ispanstream>; +#else + std::basic_ispanstream; +#endif // Mode static_assert(std::constructible_from); @@ -88,7 +81,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae_with_nasty_char(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index 45985aed49c61..b0326f82451ed 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -188,4 +188,4 @@ int main(int, char**) { #endif return 0; -} \ No newline at end of file +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp index 2423c92fda9f8..322ac32e1126c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp @@ -49,7 +49,14 @@ void test_sfinae_with_nasty_char() { template > void test_sfinae() { - using SpStream = std::basic_spanstream; + using SpStream = +#ifndef TEST_HAS_NO_NASTY_STRING + std::conditional_t, + std::basic_ispanstream, + std::basic_ispanstream>; +#else + std::basic_ispanstream; +#endif // Mode static_assert(std::constructible_from, std::ios_base::openmode>); @@ -123,7 +130,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae_with_nasty_char(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); @@ -137,4 +144,4 @@ int main(int, char**) { #endif return 0; -} \ No newline at end of file +} From b2eca6c5509a7d5be74d6a71d242db34d4a407e2 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 17:24:55 +0200 Subject: [PATCH 023/120] Tests: WIP cleanup --- .../ispanstream/ispanstream.cons/ros.pass.cpp | 9 +------ .../ispanstream.cons/span.mode.pass.cpp | 16 +----------- .../ospanstream.cons/span.mode.pass.cpp | 9 +------ .../spanbuf/spanbuf.cons/mode.pass.cpp | 9 +------ .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 16 +----------- .../spanstream.cons/span.mode.pass.cpp | 25 ++----------------- 6 files changed, 7 insertions(+), 77 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp index b2cae9b9f54ce..ac64e66725f15 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp @@ -31,14 +31,7 @@ template > void test_sfinae() { - using SpStream = -#ifndef TEST_HAS_NO_NASTY_STRING - std::conditional_t, - std::basic_ispanstream, - std::basic_ispanstream>; -#else - std::basic_ispanstream; -#endif + using SpStream = std::basic_ispanstream; // Non-const convertible static_assert(std::constructible_from>); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp index a04cc578153b2..55b2aaf5c3b2b 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -33,20 +33,6 @@ #include "../../helper_macros.h" #include "../../helper_types.h" -#ifndef TEST_HAS_NO_NASTY_STRING -void test_sfinae_with_nasty_char() { - using SpStream = std::basic_ispanstream; - - // Mode - static_assert(std::constructible_from, std::ios_base::openmode>); - static_assert(!test_convertible()); - - // Non-mode - static_assert(!std::constructible_from, const NonMode>); - static_assert(!test_convertible, const NonMode>()); -} -#endif // TEST_HAS_NO_NASTY_STRING - template > void test_sfinae() { using SpStream = std::basic_ispanstream; @@ -123,7 +109,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae_with_nasty_char(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp index bf619e8f18f7e..fe274e9208c62 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp @@ -35,14 +35,7 @@ template > void test_sfinae() { - using SpStream = -#ifndef TEST_HAS_NO_NASTY_STRING - std::conditional_t, - std::basic_ispanstream, - std::basic_ispanstream>; -#else - std::basic_ispanstream; -#endif + using SpStream = std::basic_ispanstream; // Mode static_assert(std::constructible_from, std::ios_base::openmode>); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index f4d7667ca8327..d2bd64f35cb59 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -32,14 +32,7 @@ template > void test_sfinae() { - using SpStream = -#ifndef TEST_HAS_NO_NASTY_STRING - std::conditional_t, - std::basic_ispanstream, - std::basic_ispanstream>; -#else - std::basic_ispanstream; -#endif + using SpBuf = std::basic_spanbuf; // Mode static_assert(std::constructible_from); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index b0326f82451ed..fbfc2f144ab6d 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -33,20 +33,6 @@ #include "../../helper_macros.h" #include "../../helper_types.h" -#ifndef TEST_HAS_NO_NASTY_STRING -void test_sfinae_with_nasty_char() { - using SpBuf = std::basic_spanbuf; - - // Mode - static_assert(std::constructible_from, std::ios_base::openmode>); - static_assert(!test_convertible()); - - // Non-mode - static_assert(!std::constructible_from, const NonMode>); - static_assert(!test_convertible()); -} -#endif // TEST_HAS_NO_NASTY_STRING - template > void test_sfinae() { using SpBuf = std::basic_spanbuf; @@ -174,7 +160,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae_with_nasty_char(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp index 322ac32e1126c..122d210430d9f 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp @@ -33,30 +33,9 @@ #include "../../helper_macros.h" #include "../../helper_types.h" -#ifndef TEST_HAS_NO_NASTY_STRING -void test_sfinae_with_nasty_char() { - using SpStream = std::basic_spanstream; - - // Mode - static_assert(std::constructible_from, std::ios_base::openmode>); - static_assert(!test_convertible()); - - // Non-mode - static_assert(!std::constructible_from, const NonMode>); - static_assert(!test_convertible, const NonMode>()); -} -#endif // TEST_HAS_NO_NASTY_STRING - template > void test_sfinae() { - using SpStream = -#ifndef TEST_HAS_NO_NASTY_STRING - std::conditional_t, - std::basic_ispanstream, - std::basic_ispanstream>; -#else - std::basic_ispanstream; -#endif + using SpStream = std::basic_ispanstream; // Mode static_assert(std::constructible_from, std::ios_base::openmode>); @@ -130,7 +109,7 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae(); + test_sfinae(); #endif test_sfinae(); test_sfinae>(); From df9581c743bae4c23826196003b2355c9aca12fa Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 17:55:59 +0200 Subject: [PATCH 024/120] Tests: added test skelettons --- .../ispanstream.assign/move.pass.cpp | 2 + .../ispanstream.assign/swap.pass.cpp | 2 + .../swap_nonmember.pass.cpp | 2 + .../spanbuf/spanbuf.assign/move.pass.cpp | 82 ++++++++++++++++++ .../spanbuf/spanbuf.assign/swap.pass.cpp | 85 +++++++++++++++++++ .../spanbuf.assign/swap_nonmember.pass.cpp | 81 ++++++++++++++++++ .../spanbuf/spanbuf.members/span.pass.cpp | 58 +++++++++++++ .../spanbuf.members/span.span.pass.cpp | 59 +++++++++++++ ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 62 ++++++++++++++ .../seekoff.pos_type.open_mode.pass.cpp | 58 +++++++++++++ .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 58 +++++++++++++ 11 files changed, 549 insertions(+) create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp index 117e2a6828e9d..75ae944d01c82 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp @@ -34,6 +34,8 @@ void test() { CharT arr[4]; std::span sp{arr}; + // TODO: + // Mode: default { SpStream rhsSpSt{sp}; diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp index 45fc6370a06d4..1aef6a3f47629 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp @@ -33,6 +33,8 @@ void test() { CharT arr[4]; std::span sp{arr}; + // TODO: + // Mode: default { SpStream rhsSpSt{sp}; diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp index ae54e40929745..165dc72673e9f 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp @@ -29,6 +29,8 @@ void test() { CharT arr[4]; std::span sp{arr}; + // TODO: + // Mode: default { SpStream rhsSpSt{sp}; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp new file mode 100644 index 0000000000000..798a4de1ae4d4 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_streambuf { + +// // [spanbuf.cons], constructors +// +// basic_spanbuf& operator=(basic_spanbuf&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `ios_base::out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp new file mode 100644 index 0000000000000..26aed41479890 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [ispanstream.swap], swap +// void swap(basic_spanbuf& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `ios_base::out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp new file mode 100644 index 0000000000000..f92b77bfc1511 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// void swap(basic_spanbuf& x, basic_spanbuf& y); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf= std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + SpBuf spBuf(std::span{}); + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `ios_base::out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + SpBuf spBuf(std::span{}); + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf(std::span{}); + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp new file mode 100644 index 0000000000000..25cee72694163 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [spanbuf.members], member functions +// std::span span() const noexcept; + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp new file mode 100644 index 0000000000000..9b696391b746f --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [spanbuf.members], member functions +// +// void span(std::span s) noexcept; + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp new file mode 100644 index 0000000000000..039fa1f61c09a --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [spanbuf.virtuals], overridden virtual functions +// +// pos_type seekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out) override; +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out) override; + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp new file mode 100644 index 0000000000000..006d282cacc78 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [spanbuf.virtuals], overridden virtual functions +// +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out) override; + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp new file mode 100644 index 0000000000000..fe9f5c3bf9cd8 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [spanbuf.virtuals], overridden virtual functions +// basic_streambuf* setbuf(charT*, streamsize) override; + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} From 512435a4cc4d9ddd8ca9d56f28c90626bf5cba89 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 18:27:22 +0200 Subject: [PATCH 025/120] Tests: updated `iosfwd.pass.cpp` --- .../iostream.forward/iosfwd.pass.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/libcxx/test/std/input.output/iostream.forward/iosfwd.pass.cpp b/libcxx/test/std/input.output/iostream.forward/iosfwd.pass.cpp index 85fc5de128ceb..930e0b5512aae 100644 --- a/libcxx/test/std/input.output/iostream.forward/iosfwd.pass.cpp +++ b/libcxx/test/std/input.output/iostream.forward/iosfwd.pass.cpp @@ -74,6 +74,29 @@ int main(int, char**) test* >(); #endif +#if TEST_STD_VER >= 23 + test*>(); + test*>(); +# ifndef TEST_HAS_NO_WIDE_CHARACTERS + test*>(); +# endif + test*>(); + test*>(); +# ifndef TEST_HAS_NO_WIDE_CHARACTERS + test*>(); +# endif + test*>(); + test*>(); +# ifndef TEST_HAS_NO_WIDE_CHARACTERS + test*>(); +# endif + test*>(); + test*>(); +# ifndef TEST_HAS_NO_WIDE_CHARACTERS + test*>(); +# endif +#endif // TEST_STD_VER >= 23 + test* >(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test* >(); @@ -119,6 +142,13 @@ int main(int, char**) test(); test(); +#if TEST_STD_VER >= 23 + test(); + test(); + test(); + test(); +#endif // TEST_STD_VER >= 23 + test(); test(); test(); @@ -135,6 +165,13 @@ int main(int, char**) test(); test(); +# if TEST_STD_VER >= 23 + test(); + test(); + test(); + test(); +# endif // TEST_STD_VER >= 23 + test(); test(); test(); From 3125c758f192c57b8bbdadca1329f5aed37b5aa7 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 18:33:06 +0200 Subject: [PATCH 026/120] Tests: WIP fix test skelettons --- .../spanbuf/spanbuf.assign/move.pass.cpp | 66 ++++++++-------- .../spanbuf/spanbuf.assign/swap.pass.cpp | 74 +++++++++--------- .../spanbuf.assign/swap_nonmember.pass.cpp | 76 +++++++++---------- .../spanbuf/spanbuf.members/span.pass.cpp | 20 ++--- .../spanbuf.members/span.span.pass.cpp | 18 ++--- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 20 ++--- .../seekoff.pos_type.open_mode.pass.cpp | 20 ++--- .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 18 ++--- 8 files changed, 156 insertions(+), 156 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp index 798a4de1ae4d4..7702c2c51dbc8 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp @@ -35,39 +35,39 @@ void test() { std::span sp{arr}; // TODO: - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf = std::move(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode: `ios_base::in` - { - SpBuf rhsSpBuf{sp, std::ios_base::in}; - SpBuf spBuf = std::move(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode `ios_base::out` - { - SpBuf rhsSpBuf{sp, std::ios_base::out}; - SpBuf spBuf = std::move(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: multiple - { - SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpBuf spBuf = std::move(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } + (void)sp; + // // Mode: default + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf = std::move(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } + // // Mode: `ios_base::in` + // { + // SpBuf rhsSpBuf{sp, std::ios_base::in}; + // SpBuf spBuf = std::move(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } + // // Mode `ios_base::out` + // { + // SpBuf rhsSpBuf{sp, std::ios_base::out}; + // SpBuf spBuf = std::move(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(spBuf.span().empty()); + // assert(spBuf.span().size() == 0); + // } + // // Mode: multiple + // { + // SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + // SpBuf spBuf = std::move(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(spBuf.span().empty()); + // assert(spBuf.span().size() == 0); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index 26aed41479890..e5a2fff2ba8ba 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -34,43 +34,43 @@ void test() { std::span sp{arr}; // TODO: - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode: `ios_base::in` - { - SpBuf rhsSpBuf{sp, std::ios_base::in}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode `ios_base::out` - { - SpBuf rhsSpBuf{sp, std::ios_base::out}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: multiple - { - SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } + (void)sp; + // // Mode: default + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } + // // Mode: `ios_base::in` + // { + // SpBuf rhsSpBuf{sp, std::ios_base::in}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } + // // Mode `ios_base::out` + // { + // SpBuf rhsSpBuf{sp, std::ios_base::out}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(spBuf.span().empty()); + // assert(spBuf.span().size() == 0); + // } + // // Mode: multiple + // { + // SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(spBuf.span().empty()); + // assert(spBuf.span().size() == 0); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index f92b77bfc1511..e3342253bc741 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -24,49 +24,49 @@ template > void test() { - using SpBuf= std::basic_spanbuf; + using SpBuf = std::basic_spanbuf; CharT arr[4]; std::span sp{arr}; // TODO: - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - std::swap(spBuf, rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode: `ios_base::in` - { - SpBuf rhsSpBuf{sp, std::ios_base::in}; - SpBuf spBuf(std::span{}); - std::swap(spBuf, rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode `ios_base::out` - { - SpBuf rhsSpBuf{sp, std::ios_base::out}; - SpBuf spBuf(std::span{}); - std::swap(spBuf, rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: multiple - { - SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpBuf spBuf(std::span{}); - std::swap(spBuf, rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } + (void)sp; + // // Mode: default + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // std::swap(spBuf, rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } + // // Mode: `ios_base::in` + // { + // SpBuf rhsSpBuf{sp, std::ios_base::in}; + // SpBuf spBuf(std::span{}); + // std::swap(spBuf, rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } + // // Mode `ios_base::out` + // { + // SpBuf rhsSpBuf{sp, std::ios_base::out}; + // SpBuf spBuf(std::span{}); + // std::swap(spBuf, rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(spBuf.span().empty()); + // assert(spBuf.span().size() == 0); + // } + // // Mode: multiple + // { + // SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + // SpBuf spBuf(std::span{}); + // std::swap(spBuf, rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(spBuf.span().empty()); + // assert(spBuf.span().size() == 0); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 25cee72694163..10316fe19f9ff 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -34,16 +34,16 @@ void test() { std::span sp{arr}; // TODO: - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } + (void)sp; + // // Mode: default + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index 9b696391b746f..8a0e3adc9df0e 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -35,16 +35,16 @@ void test() { std::span sp{arr}; // TODO: - + (void)sp; // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index 039fa1f61c09a..341e9f3f61d24 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -38,16 +38,16 @@ void test() { std::span sp{arr}; // TODO: - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } + (void)sp; + // // Mode: default + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp index 006d282cacc78..08b6cade94fb3 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp @@ -34,16 +34,16 @@ void test() { CharT arr[4]; std::span sp{arr}; - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } + (void)sp; + // // Mode: default + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index fe9f5c3bf9cd8..50e5b02a01c25 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -34,16 +34,16 @@ void test() { std::span sp{arr}; // TODO: - + (void)sp; // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } + // { + // SpBuf rhsSpBuf{sp}; + // SpBuf spBuf(std::span{}); + // spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + // } } int main(int, char**) { From 4fbc16b61348a42b449b3556e46e2cb976d0cb2a Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 5 Mar 2024 19:26:52 +0200 Subject: [PATCH 027/120] Tests: try to fix CI --- .../spanbuf/spanbuf.assign/move.pass.cpp | 19 +++++++++--------- .../spanbuf/spanbuf.assign/swap.pass.cpp | 20 +++++++++---------- .../spanbuf.assign/swap_nonmember.pass.cpp | 20 +++++++++---------- .../spanbuf/spanbuf.members/span.pass.cpp | 20 +++++++++---------- .../spanbuf.members/span.span.pass.cpp | 18 ++++++++--------- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 20 +++++++++---------- .../seekoff.pos_type.open_mode.pass.cpp | 20 +++++++++---------- .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 18 ++++++++--------- 8 files changed, 78 insertions(+), 77 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp index 7702c2c51dbc8..c2cc8104707be 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp @@ -35,15 +35,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; - // // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf = std::move(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf = std::move(rhsSpBuf); + (void)spBuf; + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } // // Mode: `ios_base::in` // { // SpBuf rhsSpBuf{sp, std::ios_base::in}; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index e5a2fff2ba8ba..cf036856f0b00 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -34,16 +34,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; - // // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } // // Mode: `ios_base::in` // { // SpBuf rhsSpBuf{sp, std::ios_base::in}; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index e3342253bc741..d834332bdca15 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -30,16 +30,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; - // // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // std::swap(spBuf, rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + std::swap(spBuf, rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } // // Mode: `ios_base::in` // { // SpBuf rhsSpBuf{sp, std::ios_base::in}; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 10316fe19f9ff..98e8aef0330e9 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -34,16 +34,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; - // // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index 8a0e3adc9df0e..3b3ef6704bade 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -35,16 +35,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; + // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index 341e9f3f61d24..6b4580bedb89c 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -38,16 +38,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; - // // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp index 08b6cade94fb3..0980143e67407 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp @@ -34,16 +34,16 @@ void test() { CharT arr[4]; std::span sp{arr}; - (void)sp; - // // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + + // Mode: default + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index 50e5b02a01c25..193185da8d9ca 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -34,16 +34,16 @@ void test() { std::span sp{arr}; // TODO: - (void)sp; + // Mode: default - // { - // SpBuf rhsSpBuf{sp}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } + { + SpBuf rhsSpBuf{sp}; + SpBuf spBuf(std::span{}); + spBuf.swap(rhsSpBuf); + // assert(spBuf.span().data() == arr); + // assert(!spBuf.span().empty()); + // assert(spBuf.span().size() == 4); + } } int main(int, char**) { From 7f1388cd63c22b1a26ce916db40b6582e2b64cb6 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 6 Mar 2024 14:53:21 +0200 Subject: [PATCH 028/120] Tests: WIP `span.pass` and `span.span.pass` --- libcxx/include/spanstream | 13 +-- .../input.output/span.streams/helper_types.h | 23 ++--- .../spanbuf/spanbuf.members/span.pass.cpp | 20 ++-- .../spanbuf.members/span.span.pass.cpp | 94 +++++++++++++++++-- 4 files changed, 107 insertions(+), 43 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index c735baaae93d9..f1ffd4f201368 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -66,11 +66,12 @@ #include <__utility/move.h> #include <__utility/swap.h> #include -// #include #include #include #include +// #include + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -98,11 +99,11 @@ public: _LIBCPP_HIDE_FROM_ABI basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {} _LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf(ios_base::openmode __which) - : basic_spanbuf(std::span<_CharT>(), __which) {} + : basic_streambuf<_CharT, _Traits>{}, __mode_{__which} {} _LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf(std::span<_CharT> __s, ios_base::openmode __which = ios_base::in | ios_base::out) - : basic_streambuf<_CharT, _Traits>{}, __mode_{__which}, __buf_{__s} { + : basic_streambuf<_CharT, _Traits>{}, __mode_{__which} { this->span(__s); } @@ -267,14 +268,8 @@ public: requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> _LIBCPP_HIDE_FROM_ABI explicit basic_ispanstream(_ROSeq&& __s) : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { - // std::println(stderr, "ispanstream"); std::span __sp(std::forward<_ROSeq>(__s)); - // std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); - // std::println(stderr, "span data {} {}", __sp.empty(), __sp.size()); - // std::println(stderr, "ispanstream 2"); this->span(std::span<_CharT>(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size()))); - // std::println(stderr, "span __sb_ {} {}", __sb_.span().empty(), __sb_.span().size()); - // std::println(stderr, "ispanstream 3"); } basic_ispanstream& operator=(const basic_ispanstream&) = delete; diff --git a/libcxx/test/std/input.output/span.streams/helper_types.h b/libcxx/test/std/input.output/span.streams/helper_types.h index 7f67432f9f880..79760f97e223b 100644 --- a/libcxx/test/std/input.output/span.streams/helper_types.h +++ b/libcxx/test/std/input.output/span.streams/helper_types.h @@ -16,7 +16,7 @@ #include "test_macros.h" -// #include +// ROS types template class ReadOnlySpan { @@ -25,19 +25,10 @@ class ReadOnlySpan { operator std::span() = delete; - operator std::span() { - // std::println(stderr, "----> ROspan"); - return std::span{arr_}; - } + operator std::span() { return std::span{arr_}; } - const CharT* begin() { - // std::println(stderr, "----> ROspan begin"); - return arr_; - } - const CharT* end() { - // std::println(stderr, "----> ROspan end"); - return arr_ + N; - } + const CharT* begin() { return arr_; } + const CharT* end() { return arr_ + N; } private: CharT* arr_; @@ -46,6 +37,8 @@ class ReadOnlySpan { template inline constexpr bool std::ranges::enable_borrowed_range> = true; +// Constraints: Constructors [ispanstream.cons] + static_assert(std::ranges::borrowed_range>); static_assert(!std::constructible_from, ReadOnlySpan>); @@ -96,6 +89,8 @@ class NonReadOnlySpan { template inline constexpr bool std::ranges::enable_borrowed_range> = true; +// Constraints: Constructors [ispanstream.cons] + static_assert(std::ranges::borrowed_range>); static_assert(std::constructible_from, NonReadOnlySpan>); @@ -126,7 +121,7 @@ static_assert(!std::constructible_from, const NonReadOn static_assert(!std::convertible_to, std::span>); #endif -struct SomeObject {}; +// Mode types struct NonMode {}; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 98e8aef0330e9..7d5ebea2903ea 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -31,19 +31,17 @@ void test() { using SpBuf = std::basic_spanbuf; CharT arr[4]; - std::span sp{arr}; - - // TODO: - // Mode: default + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - } + SpBuf spBuf(sp); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index 3b3ef6704bade..e1dfe517fe0d6 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -32,18 +32,94 @@ void test() { using SpBuf = std::basic_spanbuf; CharT arr[4]; - std::span sp{arr}; - // TODO: + // Mode: default (`in` | `out`) + { + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.span(arr); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + spBuf.span(sp); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `in` + { + SpBuf spBuf{std::ios_base::in}; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.span(arr); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + { + SpBuf spBuf{std::ios_base::in}; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + spBuf.span(sp); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode: `out` { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); + SpBuf spBuf{std::ios_base::out}; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.span(arr); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf{std::ios_base::out}; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + spBuf.span(sp); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); } } From 197c3be43ab43ceb487c21dd58c61f38ede39732 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 6 Mar 2024 21:59:17 +0200 Subject: [PATCH 029/120] Tests: updated `span.pass` and `span.span.pass` --- .../spanbuf/spanbuf.members/span.pass.cpp | 36 ++++++++-- .../spanbuf.members/span.span.pass.cpp | 66 +++++++++++++++---- 2 files changed, 83 insertions(+), 19 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 7d5ebea2903ea..635b8d2a03073 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -36,12 +36,38 @@ void test() { assert(sp.data() == arr); assert(!sp.empty()); assert(sp.size() == 4); - + + // Mode: default (`in` | `out`) + { + SpBuf spBuf(sp); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `in` + { + SpBuf spBuf(sp, std::ios_base::in); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode: `out` + { + SpBuf spBuf(sp, std::ios_base::out); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple { - SpBuf spBuf(sp); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); + SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index e1dfe517fe0d6..5495cdefbe7c6 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -33,6 +33,11 @@ void test() { CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + // Mode: default (`in` | `out`) { SpBuf spBuf; @@ -52,11 +57,6 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - std::span sp{arr}; - assert(sp.data() == arr); - assert(!sp.empty()); - assert(sp.size() == 4); - spBuf.span(sp); assert(spBuf.span().data() == arr); // Mode `out` counts read characters @@ -81,11 +81,6 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - std::span sp{arr}; - assert(sp.data() == arr); - assert(!sp.empty()); - assert(sp.size() == 4); - spBuf.span(sp); assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); @@ -110,10 +105,30 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - std::span sp{arr}; - assert(sp.data() == arr); - assert(!sp.empty()); - assert(sp.size() == 4); + spBuf.span(sp); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.span(arr); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); spBuf.span(sp); assert(spBuf.span().data() == arr); @@ -121,6 +136,29 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } + // Mode: `ate` + { + SpBuf spBuf(std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.span(arr); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + { + SpBuf spBuf(std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.span(sp); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } } int main(int, char**) { From ea2ed025c4156086b8b9e44c419891e94919c208 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 9 Mar 2024 07:52:45 +0200 Subject: [PATCH 030/120] Implementations: `basic_spanbuf` improved constructors and member functions --- libcxx/include/spanstream | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index f1ffd4f201368..63b61d1dee26d 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -99,12 +99,12 @@ public: _LIBCPP_HIDE_FROM_ABI basic_spanbuf() : basic_spanbuf(ios_base::in | ios_base::out) {} _LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf(ios_base::openmode __which) - : basic_streambuf<_CharT, _Traits>{}, __mode_{__which} {} + : basic_spanbuf(std::span<_CharT>(), __which) {} _LIBCPP_HIDE_FROM_ABI explicit basic_spanbuf(std::span<_CharT> __s, ios_base::openmode __which = ios_base::in | ios_base::out) - : basic_streambuf<_CharT, _Traits>{}, __mode_{__which} { - this->span(__s); + : basic_streambuf<_CharT, _Traits>{}, __mode_(__which) { + span(__s); } basic_spanbuf(const basic_spanbuf&) = delete; @@ -113,6 +113,7 @@ public: : basic_streambuf<_CharT, _Traits>{std::move(__rhs)}, __mode_{std::move(__rhs.__mode_)}, __buf_{std::move(__rhs.__buf_)} {} + // __buf_{std::exchange(__rhs.__buf_, {})} {} // [spanbuf.assign], assignment and swap @@ -120,7 +121,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_spanbuf& operator=(basic_spanbuf&& __rhs) { basic_spanbuf __tmp{std::move(__rhs)}; - this->swap(__tmp); + swap(__tmp); return *this; } @@ -134,7 +135,7 @@ public: _LIBCPP_HIDE_FROM_ABI std::span<_CharT> span() const noexcept { if (__mode_ & ios_base::out) { - return std::span<_CharT>(this->pbase(), this->pptr()); + return std::span<_CharT>{this->pbase(), this->pptr()}; } return __buf_; } @@ -158,38 +159,38 @@ protected: // [spanbuf.virtuals], overridden virtual functions _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>* setbuf(_CharT* __s, streamsize __n) override { - this->span(std::span<_CharT>(__s, __n)); + span(std::span<_CharT>(__s, __n)); return this; } _LIBCPP_HIDE_FROM_ABI pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) override { - const pos_type __error(off_type(-1)); + const auto __error = static_cast(off_type{-1}); if ((__which & ios_base::in) && (__which & ios_base::out) && (ios_base::cur == __way)) return __error; // Calculate __baseoff - off_type __baseoff; + std::size_t __baseoff; switch (__way) { case ios_base::beg: - __baseoff = off_type(0); + __baseoff = 0Z; break; case ios_base::cur: if (__which & ios_base::out) - __baseoff = off_type(this->pptr() - this->pbase()); + __baseoff = this->pptr() - this->pbase(); else - __baseoff = off_type(this->gptr() - this->eback()); + __baseoff = this->gptr() - this->eback(); break; case ios_base::end: if ((__which & ios_base::out) && !(__which & ios_base::in)) - __baseoff = off_type(this->pptr() - this->pbase()); + __baseoff = this->pptr() - this->pbase(); else - __baseoff = off_type(__buf_.size()); + __baseoff = __buf_.size(); break; default: @@ -200,29 +201,29 @@ protected: off_type __newoff; - if (__builtin_add_overflow(__baseoff, __off, &__newoff) || (__newoff < off_type(0)) || - (std::cmp_greater(__newoff, __buf_.size()))) + if (__builtin_add_overflow(__baseoff, __off, &__newoff) || (__newoff < off_type{0}) || + std::cmp_greater(__newoff, __buf_.size())) return __error; if (__which & ios_base::in) { - if ((this->gptr() == nullptr) && (__newoff != off_type(0))) + if ((this->gptr() == nullptr) && (__newoff != off_type{0})) return __error; this->setg(this->eback(), this->eback() + __newoff, this->egptr()); } if (__which & ios_base::out) { - if ((this->pptr() == nullptr) && (__newoff != off_type(0))) + if ((this->pptr() == nullptr) && (__newoff != off_type{0})) return __error; this->setp(this->pbase(), this->epptr()); this->pbump(__newoff); } - return pos_type(__newoff); + return static_cast(__newoff); } _LIBCPP_HIDE_FROM_ABI pos_type seekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out) override { - return seekoff(off_type(__sp), ios_base::beg, __which); + return seekoff(static_cast(__sp), ios_base::beg, __which); } private: From c3e0dace1dfffa6d21d2beea58dfac88f1a15fc8 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 9 Mar 2024 07:53:28 +0200 Subject: [PATCH 031/120] Tests: `basic_spanbuf` improved tests for constructors and member functions --- .../spanbuf/spanbuf.assign/move.pass.cpp | 353 ++++++++++++-- .../spanbuf/spanbuf.assign/swap.pass.cpp | 138 ++++-- .../spanbuf.assign/swap_nonmember.pass.cpp | 138 ++++-- .../spanbuf/spanbuf.cons/default.pass.cpp | 14 +- .../spanbuf/spanbuf.cons/mode.pass.cpp | 15 +- .../spanbuf/spanbuf.cons/move.pass.cpp | 449 ++++++++++++------ .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 67 ++- .../spanbuf/spanbuf.members/span.pass.cpp | 7 + 8 files changed, 912 insertions(+), 269 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp index c2cc8104707be..c1749a1068ea9 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp @@ -24,54 +24,337 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" +template +struct TestSpanBuf : std::basic_spanbuf { + using std::basic_spanbuf::basic_spanbuf; + + TestSpanBuf(std::basic_spanbuf&& rhs_p) : std::basic_spanbuf(std::move(rhs_p)) {} + + void check_postconditions(TestSpanBuf const& rhs_p) const { + assert(this->span().data() == rhs_p.span().data()); + assert(this->span().size() == rhs_p.span().size()); + assert(this->eback() == rhs_p.eback()); + assert(this->gptr() == rhs_p.gptr()); + assert(this->egptr() == rhs_p.egptr()); + assert(this->pbase() == rhs_p.pbase()); + assert(this->pptr() == rhs_p.pptr()); + assert(this->epptr() == rhs_p.epptr()); + assert(this->getloc() == rhs_p.getloc()); + } +}; + +template > +void test_postconditions() { + using SpBuf = std::basic_spanbuf; + + // Empty `span` + { + // Mode: default + { + std::span sp; + TestSpanBuf rhsSpBuf(sp); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `in` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `out` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: multiple + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ate` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::ate); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + } + + // Non-empty `span` + { + CharT arr[4]; + + // Mode: default + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `in` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `out` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: multiple + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ate` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::ate); + TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + } +} + template > void test() { using SpBuf = std::basic_spanbuf; - CharT arr[4]; - std::span sp{arr}; + // Empty `span` + { + // Mode: default (`in` | `out`) + { + SpBuf rhsSpBuf; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `in` + { + SpBuf rhsSpBuf{std::ios_base::in}; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `out` + { + SpBuf rhsSpBuf{std::ios_base::out}; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); - // TODO: + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); - // Mode: default + // After move + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ate` + { + SpBuf rhsSpBuf{std::ios_base::ate}; + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + } + + // Non-empty `span` { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf = std::move(rhsSpBuf); - (void)spBuf; - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); + CharT arr[4]; + std::span sp{arr}; + + // Mode: default (`in` | `out`) + { + SpBuf rhsSpBuf{sp}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ate` + { + SpBuf rhsSpBuf{sp, std::ios_base::ate}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + + SpBuf spBuf = std::move(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + } } - // // Mode: `ios_base::in` - // { - // SpBuf rhsSpBuf{sp, std::ios_base::in}; - // SpBuf spBuf = std::move(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } - // // Mode `ios_base::out` - // { - // SpBuf rhsSpBuf{sp, std::ios_base::out}; - // SpBuf spBuf = std::move(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(spBuf.span().empty()); - // assert(spBuf.span().size() == 0); - // } - // // Mode: multiple - // { - // SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - // SpBuf spBuf = std::move(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(spBuf.span().empty()); - // assert(spBuf.span().size() == 0); - // } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test_postconditions(); +#endif + test_postconditions(); + test_postconditions>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_postconditions(); + test_postconditions>(); +#endif +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index cf036856f0b00..6db44e92be58d 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -31,46 +31,118 @@ void test() { using SpBuf = std::basic_spanbuf; CharT arr[4]; - std::span sp{arr}; - // TODO: + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { SpBuf rhsSpBuf{sp}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + SpBuf spBuf(std::span{}); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode `ios_base::out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.swap(rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ios_base::ate` + { + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + + SpBuf spBuf(std::span{}); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); } - // // Mode: `ios_base::in` - // { - // SpBuf rhsSpBuf{sp, std::ios_base::in}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } - // // Mode `ios_base::out` - // { - // SpBuf rhsSpBuf{sp, std::ios_base::out}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(spBuf.span().empty()); - // assert(spBuf.span().size() == 0); - // } - // // Mode: multiple - // { - // SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - // SpBuf spBuf(std::span{}); - // spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(spBuf.span().empty()); - // assert(spBuf.span().size() == 0); - // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index d834332bdca15..78c5015674019 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -27,46 +27,118 @@ void test() { using SpBuf = std::basic_spanbuf; CharT arr[4]; - std::span sp{arr}; - // TODO: + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { SpBuf rhsSpBuf{sp}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ios_base::in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + SpBuf spBuf(std::span{}); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode `ios_base::out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + std::swap(spBuf, rhsSpBuf); + assert(spBuf.span().data() == arr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ios_base::ate` + { + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + + SpBuf spBuf(std::span{}); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + std::swap(spBuf, rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); } - // // Mode: `ios_base::in` - // { - // SpBuf rhsSpBuf{sp, std::ios_base::in}; - // SpBuf spBuf(std::span{}); - // std::swap(spBuf, rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - // } - // // Mode `ios_base::out` - // { - // SpBuf rhsSpBuf{sp, std::ios_base::out}; - // SpBuf spBuf(std::span{}); - // std::swap(spBuf, rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(spBuf.span().empty()); - // assert(spBuf.span().size() == 0); - // } - // // Mode: multiple - // { - // SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - // SpBuf spBuf(std::span{}); - // std::swap(spBuf, rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(spBuf.span().empty()); - // assert(spBuf.span().size() == 0); - // } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp index b76af127f4314..e1c6604b1bceb 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -21,19 +21,25 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > void test() { using SpBuf = std::basic_spanbuf; - SpBuf spBuf; - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + { + SpBuf spBuf; + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index d2bd64f35cb59..91fc5385484f7 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -47,8 +47,6 @@ template > void test() { using SpBuf = std::basic_spanbuf; - static_assert(std::default_initializable); - // Mode: `in` { SpBuf spBuf(std::ios_base::in); @@ -60,6 +58,7 @@ void test() { { SpBuf spBuf(std::ios_base::out); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } @@ -67,6 +66,15 @@ void test() { { SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read character + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `ate` + { + SpBuf spBuf(std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } @@ -78,6 +86,9 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index 1bab0f860d9f3..9252f64908de4 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -24,7 +24,7 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" template @@ -47,173 +47,314 @@ struct TestSpanBuf : std::basic_spanbuf { }; template > -void test() { +void test_postconditions() { using SpBuf = std::basic_spanbuf; + // Empty `span` + { + // Mode: default + { + std::span sp; + TestSpanBuf rhsSpBuf(sp); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `in` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `out` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: multiple + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ate` + { + std::span sp; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::ate); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == nullptr); + assert(spBuf.span().data() == nullptr); + spBuf.check_postconditions(rhsSpBuf); + } + } + + // Non-empty `span` { - // Empty `span` - { - // Mode: default - { - SpBuf rhsSpBuf; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: `ios_base::in` - { - SpBuf rhsSpBuf{std::ios_base::in}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: `ios_base::out` - { - SpBuf rhsSpBuf{std::ios_base::out}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: multiple - { - SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - } - - // Non-empty `span` - { - CharT arr[4]; + CharT arr[4]; + + // Mode: default + { std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `in` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `out` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: multiple + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ate` + { + std::span sp{arr}; + TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::ate); + TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); + assert(rhsSpBuf.span().data() == arr); + assert(spBuf.span().data() == arr); + spBuf.check_postconditions(rhsSpBuf); + } + } +} + +template > +void test() { + using SpBuf = std::basic_spanbuf; + + // Empty `span` + { + // Mode: default (`in` | `out`) + { + SpBuf rhsSpBuf; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: `ios_base::in` - { - SpBuf rhsSpBuf{sp, std::ios_base::in}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } - // Mode `ios_base::out` - { - SpBuf rhsSpBuf{sp, std::ios_base::out}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: multiple - { - SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary}; - SpBuf spBuf(std::move(rhsSpBuf)); - assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `in` + { + SpBuf rhsSpBuf{std::ios_base::in}; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `out` + { + SpBuf rhsSpBuf{std::ios_base::out}; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + assert(rhsSpBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ate` + { + SpBuf rhsSpBuf{std::ios_base::ate}; + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == nullptr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); } } - // Check post-conditions + // Non-empty `span` { - // Empty `span` - { - // Mode: default - { - std::span sp; - TestSpanBuf rhsSpBuf(sp); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == nullptr); - spBuf.check_postconditions(rhsSpBuf); - } - // Mode: `ios_base::in` - { - std::span sp; - TestSpanBuf rhsSpBuf(sp, std::ios_base::in); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == nullptr); - spBuf.check_postconditions(rhsSpBuf); - } - // Mode: `ios_base::out` - { - std::span sp; - TestSpanBuf rhsSpBuf(sp, std::ios_base::out); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == nullptr); - spBuf.check_postconditions(rhsSpBuf); - } - // Mode: multiple - { - std::span sp; - TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == nullptr); - spBuf.check_postconditions(rhsSpBuf); - } - } - - // Non-empty `span` - { - CharT arr[4]; - - // Mode: default - { - std::span sp{arr}; - TestSpanBuf rhsSpBuf(sp); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == arr); - spBuf.check_postconditions(rhsSpBuf); - } - // Mode: `ios_base::in` - { - std::span sp{arr}; - TestSpanBuf rhsSpBuf(sp, std::ios_base::in); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(!rhsSpBuf.span().empty()); - assert(spBuf.span().data() == arr); - spBuf.check_postconditions(rhsSpBuf); - } - // Mode: `ios_base::out` - { - std::span sp{arr}; - TestSpanBuf rhsSpBuf(sp, std::ios_base::out); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == arr); - spBuf.check_postconditions(rhsSpBuf); - } - // Mode: multiple - { - std::span sp{arr}; - TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); - TestSpanBuf spBuf(std::move(static_cast(rhsSpBuf))); - assert(rhsSpBuf.span().empty()); - assert(spBuf.span().data() == arr); - spBuf.check_postconditions(rhsSpBuf); - } + CharT arr[4]; + std::span sp{arr}; + + // Mode: default (`in` | `out`) + { + SpBuf rhsSpBuf{sp}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `in` + { + SpBuf rhsSpBuf{sp, std::ios_base::in}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + // Mode `out` + { + SpBuf rhsSpBuf{sp, std::ios_base::out}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + assert(rhsSpBuf.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 0); + } + // Mode: `ate` + { + SpBuf rhsSpBuf{sp, std::ios_base::ate}; + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); + + SpBuf spBuf(std::move(rhsSpBuf)); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); } } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test_postconditions(); +#endif + test_postconditions(); + test_postconditions>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_postconditions(); + test_postconditions>(); +#endif +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index fbfc2f144ab6d..dc6b6e9e5a83b 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -50,20 +50,26 @@ template > void test() { using SpBuf = std::basic_spanbuf; - static_assert(std::default_initializable); - // Empty `span` { std::span sp{}; - // Mode: default + // Mode: default (`in` | `out`) { SpBuf spBuf(sp); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: `ios_base::in` + { + SpBuf spBuf(std::as_const(sp)); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `in` { SpBuf spBuf(sp, std::ios_base::in); assert(spBuf.span().data() == nullptr); @@ -76,16 +82,18 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: `ios_base::out` + // Mode: `out` { SpBuf spBuf(sp, std::ios_base::out); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf(std::as_const(sp), std::ios_base::out); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } @@ -93,12 +101,27 @@ void test() { { SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `ate` + { + SpBuf spBuf(sp, std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } @@ -109,14 +132,22 @@ void test() { CharT arr[4]; std::span sp{arr}; - // Mode: default + // Mode: default (`in` | `out`) { SpBuf spBuf(sp); assert(spBuf.span().data() == arr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: `ios_base::in` + { + SpBuf spBuf(std::as_const(sp)); + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `in` { SpBuf spBuf(sp, std::ios_base::in); assert(spBuf.span().data() == arr); @@ -129,16 +160,18 @@ void test() { assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { SpBuf spBuf(sp, std::ios_base::out); assert(spBuf.span().data() == arr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf(std::as_const(sp), std::ios_base::out); assert(spBuf.span().data() == arr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } @@ -146,15 +179,30 @@ void test() { { SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == arr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); assert(spBuf.span().data() == arr); + // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } + // Mode: `ate` + { + SpBuf spBuf(sp, std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } + { + SpBuf spBuf(std::as_const(sp), std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } } } @@ -164,6 +212,9 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 635b8d2a03073..a13fbd10d051c 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -68,6 +68,13 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } + // Mode: `ate` + { + SpBuf spBuf(sp, std::ios_base::out | std::ios_base::ate); + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + } } int main(int, char**) { From b5d66b9ab4fd6d607d7a1bbe04d03c1049634521 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 11 Mar 2024 08:47:58 +0200 Subject: [PATCH 032/120] Tests: Added `setbuf.pass` --- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 5 +- .../seekoff.pos_type.open_mode.pass.cpp | 5 +- .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 76 ++++++++++++++++--- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index 6b4580bedb89c..2378a23dc8aef 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -27,7 +27,7 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -51,6 +51,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp index 0980143e67407..2558e2999dc09 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp @@ -25,7 +25,7 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -47,6 +47,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index 193185da8d9ca..2fd0e791e13e6 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -23,7 +23,7 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -33,20 +33,78 @@ void test() { CharT arr[4]; std::span sp{arr}; - // TODO: + // Mode: default (`in` | `out`) + { + SpBuf spBuf{sp}; + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); - // Mode: default + spBuf.pubsetbuf(nullptr, 0); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `ios_base::in` { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); + SpBuf spBuf{sp, std::ios_base::in}; + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + + spBuf.pubsetbuf(nullptr, 0); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode `ios_base::out` + { + SpBuf spBuf{sp, std::ios_base::out}; + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.pubsetbuf(nullptr, 0); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: multiple + { + SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spBuf.span().data() == arr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + + spBuf.pubsetbuf(nullptr, 0); + assert(spBuf.span().data() == nullptr); + // Mode `out` counts read characters + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); + } + // Mode: `ios_base::ate` + { + SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; + assert(spBuf.span().data() == arr); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); + + spBuf.pubsetbuf(nullptr, 0); + assert(spBuf.span().data() == nullptr); + assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS From dccf57062fb3d32952742fa4dd990c040b1ba70a Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 11 Mar 2024 12:15:48 +0200 Subject: [PATCH 033/120] Tests: WIP `seekoff` --- .../spanbuf/spanbuf.assign/move.pass.cpp | 4 +- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 200 ++++++++++++++++-- 2 files changed, 186 insertions(+), 18 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp index c1749a1068ea9..07306326b99e4 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp @@ -52,7 +52,7 @@ void test_postconditions() { // Empty `span` { - // Mode: default + // Mode: default (`in` | `out`) { std::span sp; TestSpanBuf rhsSpBuf(sp); @@ -103,7 +103,7 @@ void test_postconditions() { { CharT arr[4]; - // Mode: default + // Mode: default (`in` | `out`) { std::span sp{arr}; TestSpanBuf rhsSpBuf(sp); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index 2378a23dc8aef..b7e44293a5d69 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -18,47 +18,215 @@ // // pos_type seekoff(off_type off, ios_base::seekdir way, // ios_base::openmode which = ios_base::in | ios_base::out) override; -// pos_type seekpos(pos_type sp, -// ios_base::openmode which = ios_base::in | ios_base::out) override; +#include #include #include #include #include +// #include #include "constexpr_char_traits.h" #include "nasty_string.h" #include "test_macros.h" +// #include "../../helper_macros.h" +#include + template > void test() { - using SpBuf = std::basic_spanbuf; + using SpBuf = std::basic_spanbuf; + using SpBuffError = typename SpBuf::pos_type; - CharT arr[4]; - std::span sp{arr}; + const SpBuffError error{-1}; - // TODO: + // Empty `span` + { + std::span sp; + + // Mode: default (`in` | `out`) + { + SpBuf spBuf{sp}; + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + } + // Mode: `in` + { + SpBuf spBuf{sp, std::ios_base::in}; + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); + } + // Mode: `out` + { + SpBuf spBuf{sp, std::ios_base::out}; + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + } + // Mode: `multiple` + { + SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + } + // Mode: `ate` + { + SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); + } + } - // Mode: default + // Non-empty `span` { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); + // const CharT* cStr = CS("0123456789"); + // const std::basic_string_view sv{SV("0123456789")}; + // std::span sp{sv.begin(), sv.end()}; + + // std::print(stderr, "-=----- {}", sp); + + // Initialize with ASCII codes: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + CharT arr[]{ + CharT{48}, CharT{49}, CharT{50}, CharT{51}, CharT{52}, CharT{53}, CharT{54}, CharT{55}, CharT{56}, CharT{57}}; + std::span sp{arr}; + // std::print(stderr, "-=----- {}", sp); + // assert(false); + + // Mode: default (`in` | `out`) + { + // TestSpanBuf rhsSpBuf(sp); + // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + // assert(rhsSpBuf.span().data() == arr); + // assert(spBuf.span().data() == arr); + // spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `in` + { + SpBuf spBuf(sp, std::ios_base::in); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + // assert(spBuf.sgetc() == '3'); + assert(spBuf.sgetc() == 51); + // std::print(stderr, CS("-=-=======> {}"), spBuf.sgetc()); + std::println(stderr, "-------- {}", spBuf.sgetc()); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(spBuf.sgetc() == 54); + // std::print(stderr, CS("-=-=======> {}"), spBuf.sgetc()); + std::println(stderr, "-------- {}", spBuf.sgetc()); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(spBuf.sgetc() == 55); + // std::print(stderr, CS("-=-=======> {}"), spBuf.sgetc()); + std::println(stderr, "-------- {}", spBuf.sgetc()); + // assert(false); + } + // Mode: `out` + { + CharT resultArr[]{ + CharT{48}, CharT{49}, CharT{50}, CharT{51}, CharT{52}, CharT{53}, CharT{54}, CharT{55}, CharT{56}, CharT{57}}; + + SpBuf spBuf(sp, std::ios_base::out); + std::println(stderr, "fasdfasdfasdfasdfasd 0 {}", spBuf.span()); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(spBuf.sputc(CharT{90}) == 90); + // assert(spBuf.str() == "012a456789"); + resultArr[3] = CharT{90}; + // assert(spBuf.span() == std::span{resultArr}); + std::println(stderr, "fasdfasdfasdfasdfasd 1 {}", spBuf.span()); + std::println(stderr, "fasdfasdfasdfasdfasd {}", spBuf.span().data()); + std::println(stderr, "fasdfasdfasdfasdfasd {}", spBuf.span().size()); + std::println(stderr, "fasdfasdfasdfasdfasd 2 {}", std::span{resultArr}); + // assert(std::ranges::equal(spBuf.span(), std::span{resultArr})); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + assert(spBuf.sputc(CharT{77}) == 77); + std::println(stderr, "fasdfasdfasdfasdfasd 5 {}", spBuf.span()); + // assert(spBuf.str() == "012a456b89"); + resultArr[7] = CharT{77}; + // assert(spBuf.span() == std::span{resultArr}); + // assert(std::ranges::equal(spBuf.span(), std::span{resultArr})); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); + std::println(stderr, "fasdfasdfasdfasdfasd 6 {}", spBuf.span()); +#if 0 + assert(spBuf.sputc(CharT{84}) == 84); + // assert(spBuf.str() == "012a456c89"); + resultArr[6] = CharT{84}; + assert(spBuf.span() == std::span{resultArr}); +#endif + } + // Mode: multiple + { + // std::span sp{arr}; + // TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + // assert(rhsSpBuf.span().data() == arr); + // assert(spBuf.span().data() == arr); + // spBuf.check_postconditions(rhsSpBuf); + } + // Mode: `ate` + { + // std::span sp{arr}; + // TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::ate); + // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); + // assert(rhsSpBuf.span().data() == arr); + // assert(spBuf.span().data() == arr); + // spBuf.check_postconditions(rhsSpBuf); + } } } int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - test(); + // test(); #endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); - test>(); + // test(); + // test>(); #endif return 0; From aa4ab9b9194a04249874d443c67850c6abbc55a4 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 11 Mar 2024 15:13:37 +0200 Subject: [PATCH 034/120] Tests: WIP cleanup --- .../spanbuf/spanbuf.assign/move.pass.cpp | 1 - .../spanbuf/spanbuf.assign/swap.pass.cpp | 1 - .../spanbuf.assign/swap_nonmember.pass.cpp | 1 - .../spanbuf/spanbuf.cons/move.pass.cpp | 1 - .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 1 - .../spanbuf/spanbuf.members/span.pass.cpp | 1 - .../spanbuf.members/span.span.pass.cpp | 1 - ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 32 ++++++------------- .../seekoff.pos_type.open_mode.pass.cpp | 1 - .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 1 - 10 files changed, 9 insertions(+), 32 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp index 07306326b99e4..88179fece5908 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp @@ -19,7 +19,6 @@ // basic_spanbuf& operator=(basic_spanbuf&& rhs); #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index 6db44e92be58d..26b305333e42e 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -18,7 +18,6 @@ // void swap(basic_spanbuf& rhs); #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index 78c5015674019..681f157553326 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -14,7 +14,6 @@ // void swap(basic_spanbuf& x, basic_spanbuf& y); #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index 9252f64908de4..e9e483d290c55 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -19,7 +19,6 @@ // basic_spanbuf(basic_spanbuf&& rhs); #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index dc6b6e9e5a83b..9557b096f8f91 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -20,7 +20,6 @@ // ios_base::openmode which = ios_base::in | ios_base::out); #include -#include #include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index a13fbd10d051c..d868676c18886 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -18,7 +18,6 @@ // std::span span() const noexcept; #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index 5495cdefbe7c6..e3c836d27e349 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -19,7 +19,6 @@ // void span(std::span s) noexcept; #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index b7e44293a5d69..2d378127e5fa4 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -21,16 +21,13 @@ #include #include -#include #include #include -// #include #include "constexpr_char_traits.h" #include "nasty_string.h" #include "test_macros.h" -// #include "../../helper_macros.h" #include template > @@ -113,12 +110,6 @@ void test() { // Non-empty `span` { - // const CharT* cStr = CS("0123456789"); - // const std::basic_string_view sv{SV("0123456789")}; - // std::span sp{sv.begin(), sv.end()}; - - // std::print(stderr, "-=----- {}", sp); - // Initialize with ASCII codes: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 CharT arr[]{ CharT{48}, CharT{49}, CharT{50}, CharT{51}, CharT{52}, CharT{53}, CharT{54}, CharT{55}, CharT{56}, CharT{57}}; @@ -144,19 +135,11 @@ void test() { assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); - // assert(spBuf.sgetc() == '3'); assert(spBuf.sgetc() == 51); - // std::print(stderr, CS("-=-=======> {}"), spBuf.sgetc()); - std::println(stderr, "-------- {}", spBuf.sgetc()); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); assert(spBuf.sgetc() == 54); - // std::print(stderr, CS("-=-=======> {}"), spBuf.sgetc()); - std::println(stderr, "-------- {}", spBuf.sgetc()); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); assert(spBuf.sgetc() == 55); - // std::print(stderr, CS("-=-=======> {}"), spBuf.sgetc()); - std::println(stderr, "-------- {}", spBuf.sgetc()); - // assert(false); } // Mode: `out` { @@ -164,7 +147,7 @@ void test() { CharT{48}, CharT{49}, CharT{50}, CharT{51}, CharT{52}, CharT{53}, CharT{54}, CharT{55}, CharT{56}, CharT{57}}; SpBuf spBuf(sp, std::ios_base::out); - std::println(stderr, "fasdfasdfasdfasdfasd 0 {}", spBuf.span()); + // std::println(stderr, "fasdfasdfasdfasdfasd 0 {}", spBuf.span()); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); @@ -172,6 +155,7 @@ void test() { assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + // #if 0 assert(spBuf.sputc(CharT{90}) == 90); // assert(spBuf.str() == "012a456789"); resultArr[3] = CharT{90}; @@ -181,21 +165,23 @@ void test() { std::println(stderr, "fasdfasdfasdfasdfasd {}", spBuf.span().size()); std::println(stderr, "fasdfasdfasdfasdfasd 2 {}", std::span{resultArr}); // assert(std::ranges::equal(spBuf.span(), std::span{resultArr})); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + // assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); assert(spBuf.sputc(CharT{77}) == 77); - std::println(stderr, "fasdfasdfasdfasdfasd 5 {}", spBuf.span()); + std::println(stderr,"fasdfasdfasdfasdfasd 5 {}", spBuf.span()); // assert(spBuf.str() == "012a456b89"); resultArr[7] = CharT{77}; // assert(spBuf.span() == std::span{resultArr}); // assert(std::ranges::equal(spBuf.span(), std::span{resultArr})); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); - std::println(stderr, "fasdfasdfasdfasdfasd 6 {}", spBuf.span()); -#if 0 + // std::println(stderr, "ljjklj {}", static_cast(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out))); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 2); + std::println(stderr, "fasdfasdfasdfasdfasd 6 {}", spBuf.span()); assert(spBuf.sputc(CharT{84}) == 84); +#if 0 // assert(spBuf.str() == "012a456c89"); resultArr[6] = CharT{84}; assert(spBuf.span() == std::span{resultArr}); #endif + assert(false); } // Mode: multiple { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp index 2558e2999dc09..78fda49908601 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp @@ -20,7 +20,6 @@ // ios_base::openmode which = ios_base::in | ios_base::out) override; #include -#include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index 2fd0e791e13e6..b0d6471097998 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -18,7 +18,6 @@ // basic_streambuf* setbuf(charT*, streamsize) override; #include -#include #include #include From 08b4685d6e249817e837f8ed6d68afdf6627982f Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 12 Mar 2024 14:34:48 +0200 Subject: [PATCH 035/120] Tests: WIP `seekoff` --- libcxx/include/spanstream | 3 +- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 231 ++++--- .../temp_test/temp_test.pass.cpp | 575 ++++++++++++++++++ 3 files changed, 723 insertions(+), 86 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 63b61d1dee26d..68d65db9d0afe 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -113,7 +113,6 @@ public: : basic_streambuf<_CharT, _Traits>{std::move(__rhs)}, __mode_{std::move(__rhs.__mode_)}, __buf_{std::move(__rhs.__buf_)} {} - // __buf_{std::exchange(__rhs.__buf_, {})} {} // [spanbuf.assign], assignment and swap @@ -187,7 +186,7 @@ protected: break; case ios_base::end: - if ((__which & ios_base::out) && !(__which & ios_base::in)) + if ((__mode_ & ios_base::out) && !(__mode_ & ios_base::in)) __baseoff = this->pptr() - this->pbase(); else __baseoff = __buf_.size(); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index 2d378127e5fa4..3dac603ca1fbe 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -28,14 +28,11 @@ #include "nasty_string.h" #include "test_macros.h" -#include +#include template > void test() { - using SpBuf = std::basic_spanbuf; - using SpBuffError = typename SpBuf::pos_type; - - const SpBuffError error{-1}; + using SpBuf = std::basic_spanbuf; // Empty `span` { @@ -44,149 +41,215 @@ void test() { // Mode: default (`in` | `out`) { SpBuf spBuf{sp}; + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: `in` { SpBuf spBuf{sp, std::ios_base::in}; - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: `out` { SpBuf spBuf{sp, std::ios_base::out}; + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: `multiple` { SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: `ate` { SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } } // Non-empty `span` { - // Initialize with ASCII codes: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 - CharT arr[]{ - CharT{48}, CharT{49}, CharT{50}, CharT{51}, CharT{52}, CharT{53}, CharT{54}, CharT{55}, CharT{56}, CharT{57}}; + CharT arr[10]; std::span sp{arr}; - // std::print(stderr, "-=----- {}", sp); - // assert(false); // Mode: default (`in` | `out`) { - // TestSpanBuf rhsSpBuf(sp); - // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); - // assert(rhsSpBuf.span().data() == arr); - // assert(spBuf.span().data() == arr); - // spBuf.check_postconditions(rhsSpBuf); + SpBuf spBuf{sp}; + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + + std::cerr << spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) << std::endl; + // assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 6); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 3); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: `in` { - SpBuf spBuf(sp, std::ios_base::in); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + SpBuf spBuf{sp, std::ios_base::in}; + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); - assert(spBuf.sgetc() == 51); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); - assert(spBuf.sgetc() == 54); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); - assert(spBuf.sgetc() == 55); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: `out` { - CharT resultArr[]{ - CharT{48}, CharT{49}, CharT{50}, CharT{51}, CharT{52}, CharT{53}, CharT{54}, CharT{55}, CharT{56}, CharT{57}}; + SpBuf spBuf{sp, std::ios_base::out}; + + // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - SpBuf spBuf(sp, std::ios_base::out); - // std::println(stderr, "fasdfasdfasdfasdfasd 0 {}", spBuf.span()); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); - // #if 0 - assert(spBuf.sputc(CharT{90}) == 90); - // assert(spBuf.str() == "012a456789"); - resultArr[3] = CharT{90}; - // assert(spBuf.span() == std::span{resultArr}); - std::println(stderr, "fasdfasdfasdfasdfasd 1 {}", spBuf.span()); - std::println(stderr, "fasdfasdfasdfasdfasd {}", spBuf.span().data()); - std::println(stderr, "fasdfasdfasdfasdfasd {}", spBuf.span().size()); - std::println(stderr, "fasdfasdfasdfasdfasd 2 {}", std::span{resultArr}); - // assert(std::ranges::equal(spBuf.span(), std::span{resultArr})); - // assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); - assert(spBuf.sputc(CharT{77}) == 77); - std::println(stderr,"fasdfasdfasdfasdfasd 5 {}", spBuf.span()); - // assert(spBuf.str() == "012a456b89"); - resultArr[7] = CharT{77}; - // assert(spBuf.span() == std::span{resultArr}); - // assert(std::ranges::equal(spBuf.span(), std::span{resultArr})); - // std::println(stderr, "ljjklj {}", static_cast(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out))); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 2); - std::println(stderr, "fasdfasdfasdfasdfasd 6 {}", spBuf.span()); - assert(spBuf.sputc(CharT{84}) == 84); -#if 0 - // assert(spBuf.str() == "012a456c89"); - resultArr[6] = CharT{84}; - assert(spBuf.span() == std::span{resultArr}); -#endif - assert(false); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 6); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 3); + + // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); } // Mode: multiple { // std::span sp{arr}; - // TestSpanBuf rhsSpBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + // TestSpanBuf rhsSpBuf(sp | std::ios_base::binary); // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); // assert(rhsSpBuf.span().data() == arr); // assert(spBuf.span().data() == arr); @@ -206,13 +269,13 @@ void test() { int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING - // test(); + test(); #endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - // test(); - // test>(); + test(); + test>(); #endif return 0; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp new file mode 100644 index 0000000000000..33c75ba9b1fa8 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp @@ -0,0 +1,575 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +#include + +using namespace std; + +template +class basic_test_buf : public Spanbuf { +public: + using Spanbuf::Spanbuf; + + using Spanbuf::eback; + using Spanbuf::egptr; + using Spanbuf::epptr; + using Spanbuf::gptr; + using Spanbuf::pbase; + using Spanbuf::pptr; + + using Spanbuf::setp; + + using Spanbuf::seekoff; + using Spanbuf::seekpos; + using Spanbuf::setbuf; +}; + +template > +void test() { + using test_buf = basic_test_buf>; + { // construction + CharT buffer[10]; + const test_buf default_constructed{}; + assert(default_constructed.span().data() == nullptr); + assert(default_constructed.eback() == nullptr); + assert(default_constructed.gptr() == nullptr); + assert(default_constructed.egptr() == nullptr); + assert(default_constructed.pbase() == nullptr); + assert(default_constructed.pptr() == nullptr); + assert(default_constructed.epptr() == nullptr); + + const test_buf mode_constructed{ios_base::in}; + assert(mode_constructed.span().data() == nullptr); + assert(mode_constructed.eback() == nullptr); + assert(mode_constructed.gptr() == nullptr); + assert(mode_constructed.egptr() == nullptr); + assert(mode_constructed.pbase() == nullptr); + assert(mode_constructed.pptr() == nullptr); + assert(mode_constructed.epptr() == nullptr); + + test_buf span_constructed{span{buffer}}; + assert(span_constructed.span().data() == buffer); + assert(span_constructed.eback() == buffer); + assert(span_constructed.gptr() == buffer); + // assert(span_constructed.egptr() == std::end(buffer)); + assert(span_constructed.pbase() == buffer); + assert(span_constructed.pptr() == buffer); + // assert(span_constructed.epptr() == std::end(buffer)); + + const test_buf span_mode_in_constructed{span{buffer}, ios_base::in}; + assert(span_mode_in_constructed.span().data() == buffer); + assert(span_mode_in_constructed.eback() == buffer); + assert(span_mode_in_constructed.gptr() == buffer); + // assert(span_mode_in_constructed.egptr() == std::end(buffer)); + assert(span_mode_in_constructed.pbase() == nullptr); + assert(span_mode_in_constructed.pptr() == nullptr); + assert(span_mode_in_constructed.epptr() == nullptr); + + const test_buf span_mode_in_ate_constructed{span{buffer}, ios_base::in | ios_base::ate}; + assert(span_mode_in_ate_constructed.span().data() == buffer); + assert(span_mode_in_ate_constructed.eback() == buffer); + assert(span_mode_in_ate_constructed.gptr() == buffer); + // assert(span_mode_in_ate_constructed.egptr() == std::end(buffer)); + assert(span_mode_in_ate_constructed.pbase() == nullptr); + assert(span_mode_in_ate_constructed.pptr() == nullptr); + assert(span_mode_in_ate_constructed.epptr() == nullptr); + + const test_buf span_mode_out_constructed{span{buffer}, ios_base::out}; + assert(span_mode_out_constructed.span().data() == buffer); + assert(span_mode_out_constructed.eback() == nullptr); + assert(span_mode_out_constructed.gptr() == nullptr); + assert(span_mode_out_constructed.egptr() == nullptr); + assert(span_mode_out_constructed.pbase() == buffer); + assert(span_mode_out_constructed.pptr() == buffer); + assert(span_mode_out_constructed.epptr() == std::end(buffer)); + + const test_buf span_mode_out_ate_constructed{span{buffer}, ios_base::out | ios_base::ate}; + assert(span_mode_out_ate_constructed.span().data() == buffer); + assert(span_mode_out_ate_constructed.eback() == nullptr); + assert(span_mode_out_ate_constructed.gptr() == nullptr); + assert(span_mode_out_ate_constructed.egptr() == nullptr); + assert(span_mode_out_ate_constructed.pbase() == buffer); + // assert(span_mode_out_ate_constructed.pptr() == std::end(buffer)); + // assert(span_mode_out_ate_constructed.epptr() == std::end(buffer)); + + const test_buf span_mode_unknown_constructed{span{buffer}, 0}; + assert(span_mode_unknown_constructed.span().data() == buffer); + assert(span_mode_unknown_constructed.eback() == nullptr); + assert(span_mode_unknown_constructed.gptr() == nullptr); + assert(span_mode_unknown_constructed.egptr() == nullptr); + assert(span_mode_unknown_constructed.pbase() == nullptr); + assert(span_mode_unknown_constructed.pptr() == nullptr); + assert(span_mode_unknown_constructed.epptr() == nullptr); +#if 0 + test_buf move_constructed{std::move(span_constructed)}; + assert(move_constructed.span().data() == buffer); + assert(move_constructed.eback() == buffer); + assert(move_constructed.gptr() == buffer); + // assert(move_constructed.egptr() == std::end(buffer)); + assert(move_constructed.pbase() == buffer); + assert(move_constructed.pptr() == buffer); + // assert(move_constructed.epptr() == std::end(buffer)); + assert(span_constructed.span().data() == nullptr); + assert(span_constructed.eback() == nullptr); + assert(span_constructed.gptr() == nullptr); + assert(span_constructed.egptr() == nullptr); + assert(span_constructed.pbase() == nullptr); + assert(span_constructed.pptr() == nullptr); + assert(span_constructed.epptr() == nullptr); + + test_buf move_assigned; + move_assigned = std::move(move_constructed); + assert(move_assigned.span().data() == buffer); + assert(move_assigned.eback() == buffer); + assert(move_assigned.gptr() == buffer); + // assert(move_assigned.egptr() == std::end(buffer)); + assert(move_assigned.pbase() == buffer); + assert(move_assigned.pptr() == buffer); + // assert(move_assigned.epptr() == std::end(buffer)); + assert(move_constructed.span().data() == nullptr); + assert(move_constructed.eback() == nullptr); + assert(move_constructed.gptr() == nullptr); + assert(move_constructed.egptr() == nullptr); + assert(move_constructed.pbase() == nullptr); + assert(move_constructed.pptr() == nullptr); + assert(move_constructed.epptr() == nullptr); +#endif + } + + // { // swap + // CharT buffer1[10]; + // CharT buffer2[20]; + // test_buf first{span{buffer1}}; + // test_buf second{span{buffer2}}; + // assert(first.span().data() == buffer1); + // assert(second.span().data() == buffer2); + + // first.swap(second); + // assert(first.span().data() == buffer2); + // assert(second.span().data() == buffer1); + + // swap(first, second); + // assert(first.span().data() == buffer1); + // assert(second.span().data() == buffer2); + // } + + // { // span, span, span, span + // CharT buffer1[10]; + // test_buf input_buffer{span{buffer1}, ios_base::in}; + // assert(input_buffer.span().data() == buffer1); + // assert(input_buffer.span().size() == std::size(buffer1)); + + // test_buf output_buffer{span{buffer1}, ios_base::out}; + // assert(output_buffer.span().data() == buffer1); + // assert(output_buffer.span().size() == 0); // counts the written characters + + // // Manually move the written pointer + // output_buffer.setp(buffer1, buffer1 + 5, std::end(buffer1)); + // assert(output_buffer.span().data() == buffer1); + // assert(output_buffer.span().size() == 5); + + // CharT buffer2[10]; + // input_buffer.span(span{buffer2}); + // assert(input_buffer.span().data() == buffer2); + // assert(input_buffer.span().size() == std::size(buffer2)); + + // output_buffer.span(span{buffer2}); + // assert(output_buffer.span().data() == buffer2); + // assert(output_buffer.span().size() == 0); + + // test_buf hungry_buffer{span{buffer1}, ios_base::out | ios_base::ate}; + // assert(hungry_buffer.span().data() == buffer1); + // assert(hungry_buffer.span().size() == std::size(buffer1)); + + // hungry_buffer.span(span{buffer2}); + // assert(hungry_buffer.span().data() == buffer2); + // assert(hungry_buffer.span().size() == std::size(buffer2)); + // } + + { // seekoff ios_base::beg + CharT buffer[10]; + test_buf input_buffer{span{buffer}, ios_base::in}; + test_buf output_buffer{span{buffer}, ios_base::out}; + + auto result = input_buffer.seekoff(0, ios_base::beg, ios_base::in); + assert(result == 0); + + // pptr not set but off is 0 + result = input_buffer.seekoff(0, ios_base::beg, ios_base::out); + assert(result == 0); + + // pptr not set and off != 0 -> fail + result = input_buffer.seekoff(1, ios_base::beg, ios_base::out); + assert(result == -1); + + // gptr not set but off is 0 + result = output_buffer.seekoff(0, ios_base::beg, ios_base::in); + assert(result == 0); + + // gptr not set and off != 0 -> fail + result = output_buffer.seekoff(1, ios_base::beg, ios_base::in); + assert(result == -1); + + // negative off -> fail + result = input_buffer.seekoff(-1, ios_base::beg, ios_base::in); + assert(result == -1); + + // negative off -> fail + result = output_buffer.seekoff(-1, ios_base::beg, ios_base::out); + assert(result == -1); + + // off larger than buf -> fail + result = input_buffer.seekoff(20, ios_base::beg, ios_base::in); + assert(result == -1); + + // off larger than buf -> fail + result = output_buffer.seekoff(20, ios_base::beg, ios_base::out); + assert(result == -1); + + // passes + result = input_buffer.seekoff(5, ios_base::beg, ios_base::in); + assert(result == 5); + + result = output_buffer.seekoff(5, ios_base::beg, ios_base::out); + assert(result == 5); + + // always from front + result = input_buffer.seekoff(7, ios_base::beg, ios_base::in); + assert(result == 7); + + result = output_buffer.seekoff(7, ios_base::beg, ios_base::out); + assert(result == 7); + } + + { // seekoff ios_base::end + CharT buffer[10]; + test_buf input_buffer{span{buffer}, ios_base::in}; + // all fine we move to end of stream + auto result = input_buffer.seekoff(0, ios_base::end, ios_base::in); + assert(result == 10); + + // pptr not set but off is == 0 + result = input_buffer.seekoff(-10, ios_base::end, ios_base::out); + std::cerr << result << std::endl; + assert(result == 0); + + // pptr not set and off != 0 -> fail + result = input_buffer.seekoff(0, ios_base::end, ios_base::out); + std::cerr << result << std::endl; + assert(result == -1); + + // negative off -> fail + result = input_buffer.seekoff(-20, ios_base::end, ios_base::in); + assert(result == -1); + + // off beyond end of buffer -> fail + result = input_buffer.seekoff(1, ios_base::end, ios_base::in); + assert(result == -1); + + // passes and moves to buffer size - off + result = input_buffer.seekoff(-5, ios_base::end, ios_base::in); + assert(result == 5); + + // always from front + result = input_buffer.seekoff(-7, ios_base::end, ios_base::in); + assert(result == 3); + + // integer overflow due to large off + result = input_buffer.seekoff(numeric_limits::max(), ios_base::end, ios_base::in); + assert(result == -1); + + test_buf output_buffer{span{buffer}, ios_base::out}; + // gptr not set but off is 0 + result = output_buffer.seekoff(0, ios_base::end, ios_base::in); + assert(result == 0); + + // newoff is negative -> fail + result = output_buffer.seekoff(-10, ios_base::end, ios_base::out); + assert(result == -1); + + // pptr not set but off == 0 + result = output_buffer.seekoff(0, ios_base::end, ios_base::out); + assert(result == 0); + + // all fine we stay at end of stream + result = output_buffer.seekoff(0, ios_base::end, ios_base::in); + assert(result == 0); + + // gptr not set and off != 0 -> fail + result = output_buffer.seekoff(1, ios_base::end, ios_base::in); + assert(result == -1); + + // off + buffer size is negative -> fail + result = output_buffer.seekoff(-20, ios_base::end, ios_base::out); + assert(result == -1); + + // off larger than buffer -> fail + result = output_buffer.seekoff(11, ios_base::end, ios_base::out); + assert(result == -1); + + // passes and moves to buffer size - off + result = output_buffer.seekoff(5, ios_base::end, ios_base::out); + assert(result == 5); + + // passes we are still below buffer size + result = output_buffer.seekoff(3, ios_base::end, ios_base::out); + assert(result == 8); + + // moves beyond buffer size -> fails + result = output_buffer.seekoff(3, ios_base::end, ios_base::out); + assert(result == -1); + + // integer overflow due to large off + result = output_buffer.seekoff(numeric_limits::max(), ios_base::end, ios_base::in); + assert(result == -1); + + test_buf inout_buffer{span{buffer}, ios_base::in | ios_base::out}; + // all fine we move to end of stream + result = inout_buffer.seekoff(0, ios_base::end, ios_base::in); + assert(result == 10); + + // we move to front of the buffer + result = inout_buffer.seekoff(-10, ios_base::end, ios_base::out); + assert(result == 0); + + // we move to end of buffer + result = inout_buffer.seekoff(0, ios_base::end, ios_base::out); + assert(result == 10); + + // negative off -> fail + result = inout_buffer.seekoff(-20, ios_base::end, ios_base::in); + assert(result == -1); + + // off beyond end of buffer -> fail + result = inout_buffer.seekoff(1, ios_base::end, ios_base::in); + assert(result == -1); + + // passes and moves to buffer size - off + result = inout_buffer.seekoff(-5, ios_base::end, ios_base::in); + assert(result == 5); + + // always from front + result = inout_buffer.seekoff(-7, ios_base::end, ios_base::in); + assert(result == 3); + + // integer overflow due to large off + result = inout_buffer.seekoff(numeric_limits::max(), ios_base::end, ios_base::in); + assert(result == -1); + } + + { // seekoff ios_base::cur + CharT buffer[10]; + test_buf input_buffer{span{buffer}, ios_base::in}; + + // no mode set -> fail + auto result = input_buffer.seekoff(0, ios_base::cur, 0); + std::cerr << result << std::endl; + assert(result == -1); + + // both in and out modes set -> fail + result = input_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); + assert(result == -1); + + // pptr not set and off is != 0 -> fail + result = input_buffer.seekoff(1, ios_base::cur, ios_base::out); + assert(result == -1); + + // off larger than buffer size -> fail + result = input_buffer.seekoff(20, ios_base::cur, ios_base::out); + assert(result == -1); + + // off negative -> fail + result = input_buffer.seekoff(-1, ios_base::cur, ios_base::out); + assert(result == -1); + + // pptr not set but off is == 0 + result = input_buffer.seekoff(0, ios_base::cur, ios_base::out); + assert(result == 0); + + // passes and sets position + result = input_buffer.seekoff(3, ios_base::cur, ios_base::in); + assert(result == 3); + + // negative off moves back + result = input_buffer.seekoff(-2, ios_base::cur, ios_base::in); + assert(result == 1); + + // off + current position is beyond buffer size -> fail + result = input_buffer.seekoff(10, ios_base::cur, ios_base::in); + assert(result == -1); + + test_buf output_buffer{span{buffer}, ios_base::out}; + // no mode set -> fail + result = output_buffer.seekoff(0, ios_base::cur, 0); + std::cerr << result << std::endl; + // assert(result == -1); + + // both in and out modes set -> fail + result = output_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); + assert(result == -1); + + // gptr not set and off is != 0 -> fail + result = output_buffer.seekoff(1, ios_base::cur, ios_base::in); + assert(result == -1); + + // off larger than buffer size -> fail + result = output_buffer.seekoff(20, ios_base::cur, ios_base::out); + assert(result == -1); + + // off negative -> fail + result = output_buffer.seekoff(-1, ios_base::cur, ios_base::out); + assert(result == -1); + + // gptr not set but off is == 0 + result = output_buffer.seekoff(0, ios_base::cur, ios_base::in); + assert(result == 0); + + // passes and sets position + result = output_buffer.seekoff(3, ios_base::cur, ios_base::out); + assert(result == 3); + + // negative off moves back + result = output_buffer.seekoff(-2, ios_base::cur, ios_base::out); + assert(result == 1); + + // off + current position is beyond buffer size -> fail + result = output_buffer.seekoff(10, ios_base::cur, ios_base::out); + assert(result == -1); + + test_buf inout_buffer{span{buffer}, ios_base::in | ios_base::out}; + // no mode set -> fail + result = inout_buffer.seekoff(0, ios_base::cur, 0); + std::cerr << result << std::endl; + // assert(result == -1); + + // both in and out modes set -> fail + result = inout_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); + assert(result == -1); + + // off larger than buffer size -> fail + result = inout_buffer.seekoff(20, ios_base::cur, ios_base::out); + assert(result == -1); + + // off negative -> fail + result = inout_buffer.seekoff(-1, ios_base::cur, ios_base::out); + assert(result == -1); + + // Moves input sequence to position 3 + result = inout_buffer.seekoff(3, ios_base::cur, ios_base::in); + assert(result == 3); + + // Moves output sequence to position 3 + result = inout_buffer.seekoff(3, ios_base::cur, ios_base::out); + assert(result == 3); + + // negative off moves back + result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::in); + assert(result == 1); + + // negative off moves back + result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::out); + assert(result == 1); + + // off + current position is beyond buffer size -> fail + result = inout_buffer.seekoff(10, ios_base::cur, ios_base::in); + assert(result == -1); + + // off + current position is beyond buffer size -> fail + result = inout_buffer.seekoff(10, ios_base::cur, ios_base::out); + assert(result == -1); + + // off + current position is before buffer size -> fail + result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::in); + assert(result == -1); + + // off + current position is before buffer size -> fail + result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::out); + assert(result == -1); + } + + { // seekpos (same as seekoff with ios_base::beg) + CharT buffer[10]; + test_buf input_buffer{span{buffer}, ios_base::in}; + test_buf output_buffer{span{buffer}, ios_base::out}; + + auto result = input_buffer.seekpos(0, ios_base::in); + assert(result == 0); + + // pptr not set but off is 0 + result = input_buffer.seekpos(0, ios_base::out); + assert(result == 0); + + // pptr not set and off != 0 -> fail + result = input_buffer.seekpos(1, ios_base::out); + assert(result == -1); + + // gptr not set but off is 0 + result = output_buffer.seekpos(0, ios_base::in); + assert(result == 0); + + // gptr not set and off != 0 -> fail + result = output_buffer.seekpos(1, ios_base::in); + assert(result == -1); + + // negative off -> fail + result = input_buffer.seekpos(-1, ios_base::in); + assert(result == -1); + + // negative off -> fail + result = output_buffer.seekpos(-1, ios_base::out); + assert(result == -1); + + // off larger than buf -> fail + result = input_buffer.seekpos(20, ios_base::in); + assert(result == -1); + + // off larger than buf -> fail + result = output_buffer.seekpos(20, ios_base::out); + assert(result == -1); + + // passes + result = input_buffer.seekpos(5, ios_base::in); + assert(result == 5); + + result = output_buffer.seekpos(5, ios_base::out); + assert(result == 5); + + // always from front + result = input_buffer.seekpos(7, ios_base::in); + assert(result == 7); + + result = output_buffer.seekpos(7, ios_base::out); + assert(result == 7); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + // test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} From dee214b20dbec6756a35f0e1decd519a526ff98f Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 12 Mar 2024 17:39:41 +0200 Subject: [PATCH 036/120] Implementation: `seekoff` no mode is set --- libcxx/include/spanstream | 9 +++++++++ .../spanbuf.virtuals/temp_test/temp_test.pass.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 68d65db9d0afe..ed998566f1541 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -166,8 +166,12 @@ protected: seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) override { const auto __error = static_cast(off_type{-1}); + // Both `in` and `out` modes are set if ((__which & ios_base::in) && (__which & ios_base::out) && (ios_base::cur == __way)) return __error; + // No mode is set + if (!((__which & ios_base::in) || (__which & ios_base::out)) && (ios_base::cur == __way)) + return __error; // Calculate __baseoff @@ -204,6 +208,11 @@ protected: std::cmp_greater(__newoff, __buf_.size())) return __error; + // if (((__which & ios_base::in && (this->gptr() == nullptr)) || + // (__which & ios_base::out && (this->pptr() == nullptr))) && + // (__newoff != off_type{0})) + // return __error; + if (__which & ios_base::in) { if ((this->gptr() == nullptr) && (__newoff != off_type{0})) return __error; diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp index 33c75ba9b1fa8..8c613e2a26bfd 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp @@ -267,12 +267,12 @@ void test() { // pptr not set but off is == 0 result = input_buffer.seekoff(-10, ios_base::end, ios_base::out); - std::cerr << result << std::endl; + // std::cerr << result << std::endl; assert(result == 0); // pptr not set and off != 0 -> fail result = input_buffer.seekoff(0, ios_base::end, ios_base::out); - std::cerr << result << std::endl; + // std::cerr << result << std::endl; assert(result == -1); // negative off -> fail @@ -419,7 +419,7 @@ void test() { // no mode set -> fail result = output_buffer.seekoff(0, ios_base::cur, 0); std::cerr << result << std::endl; - // assert(result == -1); + assert(result == -1); // both in and out modes set -> fail result = output_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); @@ -457,7 +457,7 @@ void test() { // no mode set -> fail result = inout_buffer.seekoff(0, ios_base::cur, 0); std::cerr << result << std::endl; - // assert(result == -1); + assert(result == -1); // both in and out modes set -> fail result = inout_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); From b0ea4c3c805ab38e7cadd567acfc208c114805be Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 12 Mar 2024 21:12:10 +0200 Subject: [PATCH 037/120] Tests: WIP `seekoff.pass` --- libcxx/include/spanstream | 16 +- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 15 +- .../temp_test/temp_test.pass.cpp | 575 ------------------ 3 files changed, 13 insertions(+), 593 deletions(-) delete mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index ed998566f1541..2b4b6b79d86fd 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -70,8 +70,6 @@ #include #include -// #include - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -166,14 +164,15 @@ protected: seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) override { const auto __error = static_cast(off_type{-1}); - // Both `in` and `out` modes are set + // Mode: `in` and `out` if ((__which & ios_base::in) && (__which & ios_base::out) && (ios_base::cur == __way)) return __error; - // No mode is set + + // Mode: none if (!((__which & ios_base::in) || (__which & ios_base::out)) && (ios_base::cur == __way)) return __error; - // Calculate __baseoff + // Calculate `__baseoff` std::size_t __baseoff; @@ -200,7 +199,7 @@ protected: return __error; }; - // Calculate __newoff + // Calculate `__newoff` off_type __newoff; @@ -208,10 +207,7 @@ protected: std::cmp_greater(__newoff, __buf_.size())) return __error; - // if (((__which & ios_base::in && (this->gptr() == nullptr)) || - // (__which & ios_base::out && (this->pptr() == nullptr))) && - // (__newoff != off_type{0})) - // return __error; + // Set pointers if (__which & ios_base::in) { if ((this->gptr() == nullptr) && (__newoff != off_type{0})) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index 3dac603ca1fbe..e5814eaeabe77 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -182,19 +182,18 @@ void test() { assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - std::cerr << spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) << std::endl; - // assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 6); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 3); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); // Default `in` && `out` - assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::beg) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == 7); } // Mode: `in` { @@ -244,7 +243,7 @@ void test() { // Default `in` && `out` assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == 0); } // Mode: multiple { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp deleted file mode 100644 index 8c613e2a26bfd..0000000000000 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/temp_test/temp_test.pass.cpp +++ /dev/null @@ -1,575 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "constexpr_char_traits.h" -#include "nasty_string.h" -#include "test_macros.h" - -#include - -using namespace std; - -template -class basic_test_buf : public Spanbuf { -public: - using Spanbuf::Spanbuf; - - using Spanbuf::eback; - using Spanbuf::egptr; - using Spanbuf::epptr; - using Spanbuf::gptr; - using Spanbuf::pbase; - using Spanbuf::pptr; - - using Spanbuf::setp; - - using Spanbuf::seekoff; - using Spanbuf::seekpos; - using Spanbuf::setbuf; -}; - -template > -void test() { - using test_buf = basic_test_buf>; - { // construction - CharT buffer[10]; - const test_buf default_constructed{}; - assert(default_constructed.span().data() == nullptr); - assert(default_constructed.eback() == nullptr); - assert(default_constructed.gptr() == nullptr); - assert(default_constructed.egptr() == nullptr); - assert(default_constructed.pbase() == nullptr); - assert(default_constructed.pptr() == nullptr); - assert(default_constructed.epptr() == nullptr); - - const test_buf mode_constructed{ios_base::in}; - assert(mode_constructed.span().data() == nullptr); - assert(mode_constructed.eback() == nullptr); - assert(mode_constructed.gptr() == nullptr); - assert(mode_constructed.egptr() == nullptr); - assert(mode_constructed.pbase() == nullptr); - assert(mode_constructed.pptr() == nullptr); - assert(mode_constructed.epptr() == nullptr); - - test_buf span_constructed{span{buffer}}; - assert(span_constructed.span().data() == buffer); - assert(span_constructed.eback() == buffer); - assert(span_constructed.gptr() == buffer); - // assert(span_constructed.egptr() == std::end(buffer)); - assert(span_constructed.pbase() == buffer); - assert(span_constructed.pptr() == buffer); - // assert(span_constructed.epptr() == std::end(buffer)); - - const test_buf span_mode_in_constructed{span{buffer}, ios_base::in}; - assert(span_mode_in_constructed.span().data() == buffer); - assert(span_mode_in_constructed.eback() == buffer); - assert(span_mode_in_constructed.gptr() == buffer); - // assert(span_mode_in_constructed.egptr() == std::end(buffer)); - assert(span_mode_in_constructed.pbase() == nullptr); - assert(span_mode_in_constructed.pptr() == nullptr); - assert(span_mode_in_constructed.epptr() == nullptr); - - const test_buf span_mode_in_ate_constructed{span{buffer}, ios_base::in | ios_base::ate}; - assert(span_mode_in_ate_constructed.span().data() == buffer); - assert(span_mode_in_ate_constructed.eback() == buffer); - assert(span_mode_in_ate_constructed.gptr() == buffer); - // assert(span_mode_in_ate_constructed.egptr() == std::end(buffer)); - assert(span_mode_in_ate_constructed.pbase() == nullptr); - assert(span_mode_in_ate_constructed.pptr() == nullptr); - assert(span_mode_in_ate_constructed.epptr() == nullptr); - - const test_buf span_mode_out_constructed{span{buffer}, ios_base::out}; - assert(span_mode_out_constructed.span().data() == buffer); - assert(span_mode_out_constructed.eback() == nullptr); - assert(span_mode_out_constructed.gptr() == nullptr); - assert(span_mode_out_constructed.egptr() == nullptr); - assert(span_mode_out_constructed.pbase() == buffer); - assert(span_mode_out_constructed.pptr() == buffer); - assert(span_mode_out_constructed.epptr() == std::end(buffer)); - - const test_buf span_mode_out_ate_constructed{span{buffer}, ios_base::out | ios_base::ate}; - assert(span_mode_out_ate_constructed.span().data() == buffer); - assert(span_mode_out_ate_constructed.eback() == nullptr); - assert(span_mode_out_ate_constructed.gptr() == nullptr); - assert(span_mode_out_ate_constructed.egptr() == nullptr); - assert(span_mode_out_ate_constructed.pbase() == buffer); - // assert(span_mode_out_ate_constructed.pptr() == std::end(buffer)); - // assert(span_mode_out_ate_constructed.epptr() == std::end(buffer)); - - const test_buf span_mode_unknown_constructed{span{buffer}, 0}; - assert(span_mode_unknown_constructed.span().data() == buffer); - assert(span_mode_unknown_constructed.eback() == nullptr); - assert(span_mode_unknown_constructed.gptr() == nullptr); - assert(span_mode_unknown_constructed.egptr() == nullptr); - assert(span_mode_unknown_constructed.pbase() == nullptr); - assert(span_mode_unknown_constructed.pptr() == nullptr); - assert(span_mode_unknown_constructed.epptr() == nullptr); -#if 0 - test_buf move_constructed{std::move(span_constructed)}; - assert(move_constructed.span().data() == buffer); - assert(move_constructed.eback() == buffer); - assert(move_constructed.gptr() == buffer); - // assert(move_constructed.egptr() == std::end(buffer)); - assert(move_constructed.pbase() == buffer); - assert(move_constructed.pptr() == buffer); - // assert(move_constructed.epptr() == std::end(buffer)); - assert(span_constructed.span().data() == nullptr); - assert(span_constructed.eback() == nullptr); - assert(span_constructed.gptr() == nullptr); - assert(span_constructed.egptr() == nullptr); - assert(span_constructed.pbase() == nullptr); - assert(span_constructed.pptr() == nullptr); - assert(span_constructed.epptr() == nullptr); - - test_buf move_assigned; - move_assigned = std::move(move_constructed); - assert(move_assigned.span().data() == buffer); - assert(move_assigned.eback() == buffer); - assert(move_assigned.gptr() == buffer); - // assert(move_assigned.egptr() == std::end(buffer)); - assert(move_assigned.pbase() == buffer); - assert(move_assigned.pptr() == buffer); - // assert(move_assigned.epptr() == std::end(buffer)); - assert(move_constructed.span().data() == nullptr); - assert(move_constructed.eback() == nullptr); - assert(move_constructed.gptr() == nullptr); - assert(move_constructed.egptr() == nullptr); - assert(move_constructed.pbase() == nullptr); - assert(move_constructed.pptr() == nullptr); - assert(move_constructed.epptr() == nullptr); -#endif - } - - // { // swap - // CharT buffer1[10]; - // CharT buffer2[20]; - // test_buf first{span{buffer1}}; - // test_buf second{span{buffer2}}; - // assert(first.span().data() == buffer1); - // assert(second.span().data() == buffer2); - - // first.swap(second); - // assert(first.span().data() == buffer2); - // assert(second.span().data() == buffer1); - - // swap(first, second); - // assert(first.span().data() == buffer1); - // assert(second.span().data() == buffer2); - // } - - // { // span, span, span, span - // CharT buffer1[10]; - // test_buf input_buffer{span{buffer1}, ios_base::in}; - // assert(input_buffer.span().data() == buffer1); - // assert(input_buffer.span().size() == std::size(buffer1)); - - // test_buf output_buffer{span{buffer1}, ios_base::out}; - // assert(output_buffer.span().data() == buffer1); - // assert(output_buffer.span().size() == 0); // counts the written characters - - // // Manually move the written pointer - // output_buffer.setp(buffer1, buffer1 + 5, std::end(buffer1)); - // assert(output_buffer.span().data() == buffer1); - // assert(output_buffer.span().size() == 5); - - // CharT buffer2[10]; - // input_buffer.span(span{buffer2}); - // assert(input_buffer.span().data() == buffer2); - // assert(input_buffer.span().size() == std::size(buffer2)); - - // output_buffer.span(span{buffer2}); - // assert(output_buffer.span().data() == buffer2); - // assert(output_buffer.span().size() == 0); - - // test_buf hungry_buffer{span{buffer1}, ios_base::out | ios_base::ate}; - // assert(hungry_buffer.span().data() == buffer1); - // assert(hungry_buffer.span().size() == std::size(buffer1)); - - // hungry_buffer.span(span{buffer2}); - // assert(hungry_buffer.span().data() == buffer2); - // assert(hungry_buffer.span().size() == std::size(buffer2)); - // } - - { // seekoff ios_base::beg - CharT buffer[10]; - test_buf input_buffer{span{buffer}, ios_base::in}; - test_buf output_buffer{span{buffer}, ios_base::out}; - - auto result = input_buffer.seekoff(0, ios_base::beg, ios_base::in); - assert(result == 0); - - // pptr not set but off is 0 - result = input_buffer.seekoff(0, ios_base::beg, ios_base::out); - assert(result == 0); - - // pptr not set and off != 0 -> fail - result = input_buffer.seekoff(1, ios_base::beg, ios_base::out); - assert(result == -1); - - // gptr not set but off is 0 - result = output_buffer.seekoff(0, ios_base::beg, ios_base::in); - assert(result == 0); - - // gptr not set and off != 0 -> fail - result = output_buffer.seekoff(1, ios_base::beg, ios_base::in); - assert(result == -1); - - // negative off -> fail - result = input_buffer.seekoff(-1, ios_base::beg, ios_base::in); - assert(result == -1); - - // negative off -> fail - result = output_buffer.seekoff(-1, ios_base::beg, ios_base::out); - assert(result == -1); - - // off larger than buf -> fail - result = input_buffer.seekoff(20, ios_base::beg, ios_base::in); - assert(result == -1); - - // off larger than buf -> fail - result = output_buffer.seekoff(20, ios_base::beg, ios_base::out); - assert(result == -1); - - // passes - result = input_buffer.seekoff(5, ios_base::beg, ios_base::in); - assert(result == 5); - - result = output_buffer.seekoff(5, ios_base::beg, ios_base::out); - assert(result == 5); - - // always from front - result = input_buffer.seekoff(7, ios_base::beg, ios_base::in); - assert(result == 7); - - result = output_buffer.seekoff(7, ios_base::beg, ios_base::out); - assert(result == 7); - } - - { // seekoff ios_base::end - CharT buffer[10]; - test_buf input_buffer{span{buffer}, ios_base::in}; - // all fine we move to end of stream - auto result = input_buffer.seekoff(0, ios_base::end, ios_base::in); - assert(result == 10); - - // pptr not set but off is == 0 - result = input_buffer.seekoff(-10, ios_base::end, ios_base::out); - // std::cerr << result << std::endl; - assert(result == 0); - - // pptr not set and off != 0 -> fail - result = input_buffer.seekoff(0, ios_base::end, ios_base::out); - // std::cerr << result << std::endl; - assert(result == -1); - - // negative off -> fail - result = input_buffer.seekoff(-20, ios_base::end, ios_base::in); - assert(result == -1); - - // off beyond end of buffer -> fail - result = input_buffer.seekoff(1, ios_base::end, ios_base::in); - assert(result == -1); - - // passes and moves to buffer size - off - result = input_buffer.seekoff(-5, ios_base::end, ios_base::in); - assert(result == 5); - - // always from front - result = input_buffer.seekoff(-7, ios_base::end, ios_base::in); - assert(result == 3); - - // integer overflow due to large off - result = input_buffer.seekoff(numeric_limits::max(), ios_base::end, ios_base::in); - assert(result == -1); - - test_buf output_buffer{span{buffer}, ios_base::out}; - // gptr not set but off is 0 - result = output_buffer.seekoff(0, ios_base::end, ios_base::in); - assert(result == 0); - - // newoff is negative -> fail - result = output_buffer.seekoff(-10, ios_base::end, ios_base::out); - assert(result == -1); - - // pptr not set but off == 0 - result = output_buffer.seekoff(0, ios_base::end, ios_base::out); - assert(result == 0); - - // all fine we stay at end of stream - result = output_buffer.seekoff(0, ios_base::end, ios_base::in); - assert(result == 0); - - // gptr not set and off != 0 -> fail - result = output_buffer.seekoff(1, ios_base::end, ios_base::in); - assert(result == -1); - - // off + buffer size is negative -> fail - result = output_buffer.seekoff(-20, ios_base::end, ios_base::out); - assert(result == -1); - - // off larger than buffer -> fail - result = output_buffer.seekoff(11, ios_base::end, ios_base::out); - assert(result == -1); - - // passes and moves to buffer size - off - result = output_buffer.seekoff(5, ios_base::end, ios_base::out); - assert(result == 5); - - // passes we are still below buffer size - result = output_buffer.seekoff(3, ios_base::end, ios_base::out); - assert(result == 8); - - // moves beyond buffer size -> fails - result = output_buffer.seekoff(3, ios_base::end, ios_base::out); - assert(result == -1); - - // integer overflow due to large off - result = output_buffer.seekoff(numeric_limits::max(), ios_base::end, ios_base::in); - assert(result == -1); - - test_buf inout_buffer{span{buffer}, ios_base::in | ios_base::out}; - // all fine we move to end of stream - result = inout_buffer.seekoff(0, ios_base::end, ios_base::in); - assert(result == 10); - - // we move to front of the buffer - result = inout_buffer.seekoff(-10, ios_base::end, ios_base::out); - assert(result == 0); - - // we move to end of buffer - result = inout_buffer.seekoff(0, ios_base::end, ios_base::out); - assert(result == 10); - - // negative off -> fail - result = inout_buffer.seekoff(-20, ios_base::end, ios_base::in); - assert(result == -1); - - // off beyond end of buffer -> fail - result = inout_buffer.seekoff(1, ios_base::end, ios_base::in); - assert(result == -1); - - // passes and moves to buffer size - off - result = inout_buffer.seekoff(-5, ios_base::end, ios_base::in); - assert(result == 5); - - // always from front - result = inout_buffer.seekoff(-7, ios_base::end, ios_base::in); - assert(result == 3); - - // integer overflow due to large off - result = inout_buffer.seekoff(numeric_limits::max(), ios_base::end, ios_base::in); - assert(result == -1); - } - - { // seekoff ios_base::cur - CharT buffer[10]; - test_buf input_buffer{span{buffer}, ios_base::in}; - - // no mode set -> fail - auto result = input_buffer.seekoff(0, ios_base::cur, 0); - std::cerr << result << std::endl; - assert(result == -1); - - // both in and out modes set -> fail - result = input_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); - assert(result == -1); - - // pptr not set and off is != 0 -> fail - result = input_buffer.seekoff(1, ios_base::cur, ios_base::out); - assert(result == -1); - - // off larger than buffer size -> fail - result = input_buffer.seekoff(20, ios_base::cur, ios_base::out); - assert(result == -1); - - // off negative -> fail - result = input_buffer.seekoff(-1, ios_base::cur, ios_base::out); - assert(result == -1); - - // pptr not set but off is == 0 - result = input_buffer.seekoff(0, ios_base::cur, ios_base::out); - assert(result == 0); - - // passes and sets position - result = input_buffer.seekoff(3, ios_base::cur, ios_base::in); - assert(result == 3); - - // negative off moves back - result = input_buffer.seekoff(-2, ios_base::cur, ios_base::in); - assert(result == 1); - - // off + current position is beyond buffer size -> fail - result = input_buffer.seekoff(10, ios_base::cur, ios_base::in); - assert(result == -1); - - test_buf output_buffer{span{buffer}, ios_base::out}; - // no mode set -> fail - result = output_buffer.seekoff(0, ios_base::cur, 0); - std::cerr << result << std::endl; - assert(result == -1); - - // both in and out modes set -> fail - result = output_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); - assert(result == -1); - - // gptr not set and off is != 0 -> fail - result = output_buffer.seekoff(1, ios_base::cur, ios_base::in); - assert(result == -1); - - // off larger than buffer size -> fail - result = output_buffer.seekoff(20, ios_base::cur, ios_base::out); - assert(result == -1); - - // off negative -> fail - result = output_buffer.seekoff(-1, ios_base::cur, ios_base::out); - assert(result == -1); - - // gptr not set but off is == 0 - result = output_buffer.seekoff(0, ios_base::cur, ios_base::in); - assert(result == 0); - - // passes and sets position - result = output_buffer.seekoff(3, ios_base::cur, ios_base::out); - assert(result == 3); - - // negative off moves back - result = output_buffer.seekoff(-2, ios_base::cur, ios_base::out); - assert(result == 1); - - // off + current position is beyond buffer size -> fail - result = output_buffer.seekoff(10, ios_base::cur, ios_base::out); - assert(result == -1); - - test_buf inout_buffer{span{buffer}, ios_base::in | ios_base::out}; - // no mode set -> fail - result = inout_buffer.seekoff(0, ios_base::cur, 0); - std::cerr << result << std::endl; - assert(result == -1); - - // both in and out modes set -> fail - result = inout_buffer.seekoff(0, ios_base::cur, ios_base::in | ios_base::out); - assert(result == -1); - - // off larger than buffer size -> fail - result = inout_buffer.seekoff(20, ios_base::cur, ios_base::out); - assert(result == -1); - - // off negative -> fail - result = inout_buffer.seekoff(-1, ios_base::cur, ios_base::out); - assert(result == -1); - - // Moves input sequence to position 3 - result = inout_buffer.seekoff(3, ios_base::cur, ios_base::in); - assert(result == 3); - - // Moves output sequence to position 3 - result = inout_buffer.seekoff(3, ios_base::cur, ios_base::out); - assert(result == 3); - - // negative off moves back - result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::in); - assert(result == 1); - - // negative off moves back - result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::out); - assert(result == 1); - - // off + current position is beyond buffer size -> fail - result = inout_buffer.seekoff(10, ios_base::cur, ios_base::in); - assert(result == -1); - - // off + current position is beyond buffer size -> fail - result = inout_buffer.seekoff(10, ios_base::cur, ios_base::out); - assert(result == -1); - - // off + current position is before buffer size -> fail - result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::in); - assert(result == -1); - - // off + current position is before buffer size -> fail - result = inout_buffer.seekoff(-2, ios_base::cur, ios_base::out); - assert(result == -1); - } - - { // seekpos (same as seekoff with ios_base::beg) - CharT buffer[10]; - test_buf input_buffer{span{buffer}, ios_base::in}; - test_buf output_buffer{span{buffer}, ios_base::out}; - - auto result = input_buffer.seekpos(0, ios_base::in); - assert(result == 0); - - // pptr not set but off is 0 - result = input_buffer.seekpos(0, ios_base::out); - assert(result == 0); - - // pptr not set and off != 0 -> fail - result = input_buffer.seekpos(1, ios_base::out); - assert(result == -1); - - // gptr not set but off is 0 - result = output_buffer.seekpos(0, ios_base::in); - assert(result == 0); - - // gptr not set and off != 0 -> fail - result = output_buffer.seekpos(1, ios_base::in); - assert(result == -1); - - // negative off -> fail - result = input_buffer.seekpos(-1, ios_base::in); - assert(result == -1); - - // negative off -> fail - result = output_buffer.seekpos(-1, ios_base::out); - assert(result == -1); - - // off larger than buf -> fail - result = input_buffer.seekpos(20, ios_base::in); - assert(result == -1); - - // off larger than buf -> fail - result = output_buffer.seekpos(20, ios_base::out); - assert(result == -1); - - // passes - result = input_buffer.seekpos(5, ios_base::in); - assert(result == 5); - - result = output_buffer.seekpos(5, ios_base::out); - assert(result == 5); - - // always from front - result = input_buffer.seekpos(7, ios_base::in); - assert(result == 7); - - result = output_buffer.seekpos(7, ios_base::out); - assert(result == 7); - } -} - -int main(int, char**) { -#ifndef TEST_HAS_NO_NASTY_STRING - // test(); -#endif - test(); - test>(); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); - test>(); -#endif - - return 0; -} From c83a5be28d7fd7c31dfc7864d4a89d760733eb82 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 13 Mar 2024 11:41:35 +0200 Subject: [PATCH 038/120] Tests: `seekoff.off_type.seek_dir.open_mode.pass` --- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 236 +++++++++++------- 1 file changed, 144 insertions(+), 92 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index e5814eaeabe77..ce9fd90f6e7c3 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -28,27 +28,30 @@ #include "nasty_string.h" #include "test_macros.h" -#include +// #include template > void test() { using SpBuf = std::basic_spanbuf; + constexpr auto no_mode = 0; + // Empty `span` { std::span sp; + // For an empty span: + // -3 is an out-of-range offset value + // 0 is an in-range offset value for an empty span + // 3 is an out-of-range offset value + // Mode: default (`in` | `out`) { SpBuf spBuf{sp}; - // Out-of-range - assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::in) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); @@ -58,48 +61,36 @@ void test() { assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); - // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + + // Default parameter value `openmode` + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end) == 0); + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + + // No mode + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 0); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-1, std::ios_base::end, no_mode) == -1); } // Mode: `in` { SpBuf spBuf{sp, std::ios_base::in}; - // Out-of-range - assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); - - // Default `in` && `out` - assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); - } - // Mode: `out` - { - SpBuf spBuf{sp, std::ios_base::out}; - - // Out-of-range - assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); @@ -108,22 +99,35 @@ void test() { assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); - // Default `in` && `out` + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + + // Default parameter value `openmode` + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? + assert(spBuf.pubseekoff(0, std::ios_base::end) == 0); + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + + // No mode + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 0); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, no_mode) == -1); } - // Mode: `multiple` + // Mode: `out` { - SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf{sp, std::ios_base::out}; - // Out-of-range - assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); @@ -133,35 +137,27 @@ void test() { assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); - // Default `in` && `out` - assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); - assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); - } - // Mode: `ate` - { - SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; - - // Out-of-range - assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); - assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - - assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); - assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); - assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); - assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); - // Default `in` && `out` + // Default parameter value `openmode` + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? + assert(spBuf.pubseekoff(0, std::ios_base::end) == 0); + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + + // No mode + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 0); + + assert(spBuf.pubseekoff(3, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(3, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, no_mode) == -1); } } @@ -170,6 +166,10 @@ void test() { CharT arr[10]; std::span sp{arr}; + // For an empty span: + // -999 is an out-of-range offset value + // 999 is an out-of-range offset value + // Mode: default (`in` | `out`) { SpBuf spBuf{sp}; @@ -182,18 +182,43 @@ void test() { assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + // In-range + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + // std::cerr << spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) << std::endl; + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 10); // ??? + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + // std::cerr << spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) << std::endl; + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 10); // ??? + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 6); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); - // Default `in` && `out` + // Default parameter value `openmode` + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); + // std::cerr << spBuf.pubseekoff(0, std::ios_base::cur) << std::endl; + assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? + assert(spBuf.pubseekoff(0, std::ios_base::end) == 10); + assert(spBuf.pubseekoff(3, std::ios_base::beg) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end) == 7); + + // No mode + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 10); // ??? + + assert(spBuf.pubseekoff(3, std::ios_base::beg, no_mode) == 3); + assert(spBuf.pubseekoff(3, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, no_mode) == 7); } // Mode: `in` { @@ -207,18 +232,41 @@ void test() { assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + // In-range + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 10); // ??? + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + // std::cerr << spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) << std::endl; + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == -1); // ??? + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); - // Default `in` && `out` + // Default parameter value `openmode` + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? + assert(spBuf.pubseekoff(0, std::ios_base::end) == -1); // ??? + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + + // No mode + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 10); // ??? + + assert(spBuf.pubseekoff(3, std::ios_base::beg, no_mode) == 3); + assert(spBuf.pubseekoff(3, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, no_mode) == 7); } // Mode: `out` { @@ -232,36 +280,40 @@ void test() { assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); + // In-range + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); assert(spBuf.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 6); assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 3); - // Default `in` && `out` + // Default parameter value `openmode` + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? + assert(spBuf.pubseekoff(0, std::ios_base::end) == 0); + assert(spBuf.pubseekoff(3, std::ios_base::beg) == -1); assert(spBuf.pubseekoff(3, std::ios_base::cur) == -1); - assert(spBuf.pubseekoff(-3, std::ios_base::end) == 0); - } - // Mode: multiple - { - // std::span sp{arr}; - // TestSpanBuf rhsSpBuf(sp | std::ios_base::binary); - // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); - // assert(rhsSpBuf.span().data() == arr); - // assert(spBuf.span().data() == arr); - // spBuf.check_postconditions(rhsSpBuf); - } - // Mode: `ate` - { - // std::span sp{arr}; - // TestSpanBuf rhsSpBuf(sp, std::ios_base::out | std::ios_base::ate); - // TestSpanBuf spBuf = std::move(static_cast(rhsSpBuf)); - // assert(rhsSpBuf.span().data() == arr); - // assert(spBuf.span().data() == arr); - // spBuf.check_postconditions(rhsSpBuf); + assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); + + // No mode + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); + assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 0); // ??? + + assert(spBuf.pubseekoff(3, std::ios_base::beg, no_mode) == 3); + assert(spBuf.pubseekoff(3, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-3, std::ios_base::end, no_mode) == -1); // ??? } } } From 5316a76a3e1b7ea40eeeb6790b4f9d02cbe82424 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 13 Mar 2024 11:50:47 +0200 Subject: [PATCH 039/120] Tests: clean-up `seekoff.off_type.seek_dir.open_mode.pass` --- ...ekoff.off_type.seek_dir.open_mode.pass.cpp | 87 ++++++++++++++++--- 1 file changed, 75 insertions(+), 12 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp index ce9fd90f6e7c3..1a3d43f99b0ff 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp @@ -28,8 +28,6 @@ #include "nasty_string.h" #include "test_macros.h" -// #include - template > void test() { using SpBuf = std::basic_spanbuf; @@ -174,18 +172,24 @@ void test() { { SpBuf spBuf{sp}; - // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::in) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - // In-range assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); - // std::cerr << spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) << std::endl; assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 10); // ??? assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); @@ -194,7 +198,6 @@ void test() { assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); - // std::cerr << spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) << std::endl; assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 10); // ??? assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); @@ -202,8 +205,15 @@ void test() { assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); // Default parameter value `openmode` + assert(spBuf.pubseekoff(-999, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); - // std::cerr << spBuf.pubseekoff(0, std::ios_base::cur) << std::endl; assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? assert(spBuf.pubseekoff(0, std::ios_base::end) == 10); @@ -212,6 +222,14 @@ void test() { assert(spBuf.pubseekoff(-3, std::ios_base::end) == 7); // No mode + assert(spBuf.pubseekoff(-999, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, no_mode) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 10); // ??? @@ -224,15 +242,22 @@ void test() { { SpBuf spBuf{sp, std::ios_base::in}; - // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::in) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - // In-range assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 10); // ??? @@ -243,7 +268,6 @@ void test() { assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); - // std::cerr << spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) << std::endl; assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::out) == -1); // ??? assert(spBuf.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); @@ -251,6 +275,14 @@ void test() { assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); // Default parameter value `openmode` + assert(spBuf.pubseekoff(-999, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? assert(spBuf.pubseekoff(0, std::ios_base::end) == -1); // ??? @@ -260,6 +292,14 @@ void test() { assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); // No mode + assert(spBuf.pubseekoff(-999, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, no_mode) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 10); // ??? @@ -272,15 +312,22 @@ void test() { { SpBuf spBuf{sp, std::ios_base::out}; - // Out-of-range + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::in) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::in) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(-999, std::ios_base::end, std::ios_base::out) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::beg, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::cur, std::ios_base::out) == -1); assert(spBuf.pubseekoff(999, std::ios_base::end, std::ios_base::out) == -1); - // In-range assert(spBuf.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); assert(spBuf.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); @@ -298,6 +345,14 @@ void test() { assert(spBuf.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 3); // Default parameter value `openmode` + assert(spBuf.pubseekoff(-999, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur) == -1); // ??? assert(spBuf.pubseekoff(0, std::ios_base::end) == 0); @@ -307,6 +362,14 @@ void test() { assert(spBuf.pubseekoff(-3, std::ios_base::end) == -1); // No mode + assert(spBuf.pubseekoff(-999, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(-999, std::ios_base::end, no_mode) == -1); + + assert(spBuf.pubseekoff(999, std::ios_base::beg, no_mode) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::cur, no_mode) == -1); + assert(spBuf.pubseekoff(999, std::ios_base::end, no_mode) == -1); + assert(spBuf.pubseekoff(0, std::ios_base::beg, no_mode) == 0); assert(spBuf.pubseekoff(0, std::ios_base::cur, no_mode) == -1); assert(spBuf.pubseekoff(0, std::ios_base::end, no_mode) == 0); // ??? From 6e435e05a9660c020a1f634ea71254ccdc590112 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 13 Mar 2024 13:10:16 +0200 Subject: [PATCH 040/120] Tests: updated `seekoff.pass` and `seekpos.pass` --- ...ir.open_mode.pass.cpp => seekoff.pass.cpp} | 1 - .../seekoff.pos_type.open_mode.pass.cpp | 60 ----- .../spanbuf/spanbuf.virtuals/seekpos.pass.cpp | 211 ++++++++++++++++++ 3 files changed, 211 insertions(+), 61 deletions(-) rename libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/{seekoff.off_type.seek_dir.open_mode.pass.cpp => seekoff.pass.cpp} (99%) delete mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp similarity index 99% rename from libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp rename to libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp index 1a3d43f99b0ff..006bd0786ccc8 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.off_type.seek_dir.open_mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp @@ -19,7 +19,6 @@ // pos_type seekoff(off_type off, ios_base::seekdir way, // ios_base::openmode which = ios_base::in | ios_base::out) override; -#include #include #include #include diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp deleted file mode 100644 index 78fda49908601..0000000000000 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pos_type.open_mode.pass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 - -// - -// template> -// class basic_spanbuf -// : public basic_spanbuf { - -// // [spanbuf.virtuals], overridden virtual functions -// -// pos_type seekpos(pos_type sp, -// ios_base::openmode which = ios_base::in | ios_base::out) override; - -#include -#include -#include - -#include "constexpr_char_traits.h" -#include "nasty_string.h" -#include "test_macros.h" - -template > -void test() { - using SpBuf = std::basic_spanbuf; - - CharT arr[4]; - std::span sp{arr}; - - // Mode: default - { - SpBuf rhsSpBuf{sp}; - SpBuf spBuf(std::span{}); - spBuf.swap(rhsSpBuf); - // assert(spBuf.span().data() == arr); - // assert(!spBuf.span().empty()); - // assert(spBuf.span().size() == 4); - } -} - -int main(int, char**) { -#ifndef TEST_HAS_NO_NASTY_STRING - test(); -#endif - test(); - test>(); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); - test>(); -#endif - - return 0; -} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp new file mode 100644 index 0000000000000..3b7f0d1b67323 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp @@ -0,0 +1,211 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanbuf +// : public basic_spanbuf { + +// // [spanbuf.virtuals], overridden virtual functions +// +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out) override; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +// `seekpos` is the same as `seekoff` with `ios_base::beg` +template > +void test() { + using SpBuf = std::basic_spanbuf; + + constexpr auto no_mode = 0; + + // Empty `span` + { + std::span sp; + + // For an empty span: + // 0 is an in-range offset value for an empty span + // 3 is an out-of-range offset value + + // Mode: default (`in` | `out`) + { + SpBuf spBuf{sp}; + + assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::in) == -1); + + assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::out) == -1); + + // Default parameter value `openmode` + assert(spBuf.pubseekpos(0) == 0); + assert(spBuf.pubseekpos(3) == -1); + + // No mode + assert(spBuf.pubseekpos(0, no_mode) == 0); + assert(spBuf.pubseekpos(3, no_mode) == -1); + } + // Mode: `in` + { + SpBuf spBuf{sp, std::ios_base::in}; + + assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::in) == -1); + + assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::out) == -1); + + // Default parameter value `openmode` + assert(spBuf.pubseekpos(0) == 0); + assert(spBuf.pubseekpos(3) == -1); + + // No mode + assert(spBuf.pubseekpos(0, no_mode) == 0); + assert(spBuf.pubseekpos(3, no_mode) == -1); + } + // Mode: `out` + { + SpBuf spBuf{sp, std::ios_base::out}; + + assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::in) == -1); + + assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::out) == -1); + + // Default parameter value `openmode` + assert(spBuf.pubseekpos(0) == 0); + assert(spBuf.pubseekpos(3) == -1); + + // No mode + assert(spBuf.pubseekpos(0, no_mode) == 0); + assert(spBuf.pubseekpos(3, no_mode) == -1); + } + } + + // Non-empty `span` + { + CharT arr[10]; + std::span sp{arr}; + + // For an empty span: + // 999 is an out-of-range offset value + + // Mode: default (`in` | `out`) + { + SpBuf spBuf{sp}; + + assert(spBuf.pubseekpos(999, std::ios_base::in) == -1); + + assert(spBuf.pubseekpos(999, std::ios_base::out) == -1); + + assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::in) == 3); + + assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::out) == 3); + + // Default parameter value `openmode` + assert(spBuf.pubseekpos(-999) == -1); + assert(spBuf.pubseekpos(999) == -1); + + assert(spBuf.pubseekpos(0) == 0); + assert(spBuf.pubseekpos(3) == 3); + + // No mode + assert(spBuf.pubseekpos(-999, no_mode) == -1); + assert(spBuf.pubseekpos(999, no_mode) == -1); + + assert(spBuf.pubseekpos(0, no_mode) == 0); + assert(spBuf.pubseekpos(3, no_mode) == 3); + } + // Mode: `in` + { + SpBuf spBuf{sp, std::ios_base::in}; + + assert(spBuf.pubseekpos(999, std::ios_base::in) == -1); + + + assert(spBuf.pubseekpos(999, std::ios_base::out) == -1); + + assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::in) == 3); + + + assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::out) == -1); + + + // Default parameter value `openmode` + assert(spBuf.pubseekpos(999) == -1); + + assert(spBuf.pubseekpos(0) == 0); + assert(spBuf.pubseekpos(3) == -1); + + + // No mode + assert(spBuf.pubseekpos(999, no_mode) == -1); + + assert(spBuf.pubseekpos(0, no_mode) == 0); + assert(spBuf.pubseekpos(3, no_mode) == 3); + } + // Mode: `out` + { + SpBuf spBuf{sp, std::ios_base::out}; + + assert(spBuf.pubseekpos(999, std::ios_base::in) == -1); + + + assert(spBuf.pubseekpos(999, std::ios_base::out) == -1); + + + assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::in) == -1); + + + assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); + assert(spBuf.pubseekpos(3, std::ios_base::out) == 3); + + + // Default parameter value `openmode` + assert(spBuf.pubseekpos(999) == -1); + assert(spBuf.pubseekpos(0) == 0); + assert(spBuf.pubseekpos(3) == -1); + + + // No mode + assert(spBuf.pubseekpos(999, no_mode) == -1); + assert(spBuf.pubseekpos(0, no_mode) == 0); + assert(spBuf.pubseekpos(3, no_mode) == 3); + } + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} From 7d178696825dc47e12e1c9b8947c9b906c14492a Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 13 Mar 2024 19:15:42 +0200 Subject: [PATCH 041/120] Tests: WIP `operator>>` tests --- .../spanbuf/spanbuf.virtuals/seekpos.pass.cpp | 12 +- .../spanstream/inherited.stream.ops.pass.cpp | 177 ++++++++++++++++++ 2 files changed, 178 insertions(+), 11 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp index 3b7f0d1b67323..71594c0066720 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp @@ -121,7 +121,6 @@ void test() { assert(spBuf.pubseekpos(3, std::ios_base::out) == 3); // Default parameter value `openmode` - assert(spBuf.pubseekpos(-999) == -1); assert(spBuf.pubseekpos(999) == -1); assert(spBuf.pubseekpos(0) == 0); @@ -140,24 +139,20 @@ void test() { assert(spBuf.pubseekpos(999, std::ios_base::in) == -1); - assert(spBuf.pubseekpos(999, std::ios_base::out) == -1); assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); assert(spBuf.pubseekpos(3, std::ios_base::in) == 3); - assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); assert(spBuf.pubseekpos(3, std::ios_base::out) == -1); - // Default parameter value `openmode` assert(spBuf.pubseekpos(999) == -1); assert(spBuf.pubseekpos(0) == 0); assert(spBuf.pubseekpos(3) == -1); - // No mode assert(spBuf.pubseekpos(999, no_mode) == -1); @@ -169,25 +164,20 @@ void test() { SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.pubseekpos(999, std::ios_base::in) == -1); - - + assert(spBuf.pubseekpos(999, std::ios_base::out) == -1); - assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); assert(spBuf.pubseekpos(3, std::ios_base::in) == -1); - assert(spBuf.pubseekpos(0, std::ios_base::out) == 0); assert(spBuf.pubseekpos(3, std::ios_base::out) == 3); - // Default parameter value `openmode` assert(spBuf.pubseekpos(999) == -1); assert(spBuf.pubseekpos(0) == 0); assert(spBuf.pubseekpos(3) == -1); - // No mode assert(spBuf.pubseekpos(999, no_mode) == -1); assert(spBuf.pubseekpos(0, no_mode) == 0); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp new file mode 100644 index 0000000000000..7517c301dd56f --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -0,0 +1,177 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_streambuf { + +// Test stream operations inherited from `basic_istream` and `basic_ostream` + +#include +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +#include "../helper_macros.h" + +#include +#include + +template > +void initialize_array(CharT* arr, std::basic_string_view sv) { + if constexpr (std::same_as) + strncpy(arr, sv.data(), sv.size() + 1); + else + wcsncpy(arr, sv.data(), sv.size() + 1); +} + +template > +void test() { + using SpStream = std::basic_spanstream; + + constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir ")}; + CharT arr[sv.size() + 1]; + initialize_array(arr, sv); + // if constexpr (std::same_as) + // strncpy(arr, sv.data(), sv.size() + 1); + // else + // wcsncpy(arr, sv.data(), sv.size() + 1); + + std::span sp{arr}; + + // if constexpr (std::same_as) { + // std::println(stderr, "{}", sp.data()); + // std::println(stderr, "{}", sp); + // } else { + // // std::println(stderr, "{}", sp.data()); + // // std::println(stderr, "{}", sp); + // // std::println(stderr, L"{}", L"sv.data()"); + // std::wcerr << std::format(L"L {}", sp.data()) << std::endl; + // std::wcerr << std::format(L"L {}", sp) << std::endl; + // } + + // Mode: default + { + SpStream spSt(sp); + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + + if constexpr (std::same_as) { + std::println(stderr, "str1 '{}'", str1); + std::println(stderr, "str2 '{}'", str2); + std::println(stderr, "str3 '{}'", str3); + } else { + // std::println(stderr, "{}", sp.data()); + // std::println(stderr, "{}", sp); + // std::println(stderr, L"{}", L"sv.data()"); + std::wcerr << std::format(L"L str1 '{}'", str1) << std::endl; + std::wcerr << std::format(L"L str2 '{}'", str2) << std::endl; + std::wcerr << std::format(L"L str3 '{}'", str3) << std::endl; + } + assert(str1 == CS("zmt")); + assert(i1 == 94); + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + } + // std::cerr << "========================================" << std::endl; + { + std::basic_istringstream spSt{sv.data()}; + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + + if constexpr (std::same_as) { + std::println(stderr, "- str1 '{}'", str1); + std::println(stderr, "str2 '{}'", str2); + std::println(stderr, "str3 '{}'", str3); + } else { + // std::cerr << "lfasdfasdfasdfasd" << std::endl; + // std::wcerr << std::format(L"L - str1 '{}'", L"+++++++++++++++++++++++++") << std::endl; + std::wcerr << std::format(L"L - str1 '{}'", str1) << std::endl; + std::wcerr << std::format(L"L str2 '{}'", str2) << std::endl; + std::wcerr << std::format(L"L str3 '{}'", str3) << std::endl; + } + } + + // // Mode: default + // { + // SpStream rhsSpSt{sp}; + // SpStream spSt(std::move(rhsSpSt)); + // assert(spSt.span().data() == arr); + // assert(spSt.span().empty()); + // assert(spSt.span().size() == 0); + // } + // // Mode: `ios_base::in` + // { + // SpStream rhsSpSt{sp, std::ios_base::in}; + // SpStream spSt(std::move(rhsSpSt)); + // assert(spSt.span().data() == arr); + // assert(!spSt.span().empty()); + // assert(spSt.span().size() == 4); + // } + // // Mode `ios_base::out` + // { + // SpStream rhsSpSt{sp, std::ios_base::out}; + // SpStream spSt(std::move(rhsSpSt)); + // assert(spSt.span().data() == arr); + // assert(spSt.span().empty()); + // assert(spSt.span().size() == 0); + // } + // // Mode: multiple + // { + // SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + // SpStream spSt(std::move(rhsSpSt)); + // assert(spSt.span().data() == arr); + // assert(spSt.span().empty()); + // assert(spSt.span().size() == 0); + // } +} + +int main(int, char**) { + test(); + // test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + // test>(); +#endif + // std::println(stderr, "fasdfas"); + // std::println(std::cerr, "fasdfasdfasd{}", "-----"); + // std::println(std::cout, "fasdfasdfasd{}", "-----"); + // std::println(std::wcout, L"fasdfasdfasd{}", L"-----"); + // std::println(std::wcerr, L"fasdfasdfasd{}", L"-----"); + + // assert(false); + + return 0; +} From 6b67a27b69257029dbcee328b43b71b9b54490c4 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 13 Mar 2024 20:35:09 +0200 Subject: [PATCH 042/120] Test: WIP `basic_spanstream`'s `operator>>` and `operator<<` --- .../spanstream/inherited.stream.ops.pass.cpp | 91 +++---------------- 1 file changed, 13 insertions(+), 78 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index 7517c301dd56f..febba22eee00b 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -21,17 +21,11 @@ #include #include #include -#include -#include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" #include "../helper_macros.h" -#include -#include - template > void initialize_array(CharT* arr, std::basic_string_view sv) { if constexpr (std::same_as) @@ -44,27 +38,11 @@ template > void test() { using SpStream = std::basic_spanstream; - constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir ")}; + constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; CharT arr[sv.size() + 1]; initialize_array(arr, sv); - // if constexpr (std::same_as) - // strncpy(arr, sv.data(), sv.size() + 1); - // else - // wcsncpy(arr, sv.data(), sv.size() + 1); - std::span sp{arr}; - // if constexpr (std::same_as) { - // std::println(stderr, "{}", sp.data()); - // std::println(stderr, "{}", sp); - // } else { - // // std::println(stderr, "{}", sp.data()); - // // std::println(stderr, "{}", sp); - // // std::println(stderr, L"{}", L"sv.data()"); - // std::wcerr << std::format(L"L {}", sp.data()) << std::endl; - // std::wcerr << std::format(L"L {}", sp) << std::endl; - // } - // Mode: default { SpStream spSt(sp); @@ -78,60 +56,26 @@ void test() { spSt >> i2; std::basic_string str3; spSt >> str3; + int i3; + spSt >> i3; - if constexpr (std::same_as) { - std::println(stderr, "str1 '{}'", str1); - std::println(stderr, "str2 '{}'", str2); - std::println(stderr, "str3 '{}'", str3); - } else { - // std::println(stderr, "{}", sp.data()); - // std::println(stderr, "{}", sp); - // std::println(stderr, L"{}", L"sv.data()"); - std::wcerr << std::format(L"L str1 '{}'", str1) << std::endl; - std::wcerr << std::format(L"L str2 '{}'", str2) << std::endl; - std::wcerr << std::format(L"L str3 '{}'", str3) << std::endl; - } assert(str1 == CS("zmt")); assert(i1 == 94); assert(str2 == CS("hkt")); assert(i2 == 82); assert(str3 == CS("pir")); - } - // std::cerr << "========================================" << std::endl; - { - std::basic_istringstream spSt{sv.data()}; - std::basic_string str1; - spSt >> str1; - int i1; - spSt >> i1; - std::basic_string str2; - spSt >> str2; - int i2; - spSt >> i2; - std::basic_string str3; - spSt >> str3; + assert(i3 == 43); - if constexpr (std::same_as) { - std::println(stderr, "- str1 '{}'", str1); - std::println(stderr, "str2 '{}'", str2); - std::println(stderr, "str3 '{}'", str3); - } else { - // std::cerr << "lfasdfasdfasdfasd" << std::endl; - // std::wcerr << std::format(L"L - str1 '{}'", L"+++++++++++++++++++++++++") << std::endl; - std::wcerr << std::format(L"L - str1 '{}'", str1) << std::endl; - std::wcerr << std::format(L"L str2 '{}'", str2) << std::endl; - std::wcerr << std::format(L"L str3 '{}'", str3) << std::endl; - } - } + spSt << CS("year 2024"); + spSt.seekg(0); + std::basic_string str4; + spSt >> str4; + int i4; + spSt >> i4; - // // Mode: default - // { - // SpStream rhsSpSt{sp}; - // SpStream spSt(std::move(rhsSpSt)); - // assert(spSt.span().data() == arr); - // assert(spSt.span().empty()); - // assert(spSt.span().size() == 0); - // } + assert(str4 == CS("year")); + assert(i4 == 2024); + } // // Mode: `ios_base::in` // { // SpStream rhsSpSt{sp, std::ios_base::in}; @@ -160,18 +104,9 @@ void test() { int main(int, char**) { test(); - // test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); - // test>(); #endif - // std::println(stderr, "fasdfas"); - // std::println(std::cerr, "fasdfasdfasd{}", "-----"); - // std::println(std::cout, "fasdfasdfasd{}", "-----"); - // std::println(std::wcout, L"fasdfasdfasd{}", L"-----"); - // std::println(std::wcerr, L"fasdfasdfasd{}", L"-----"); - - // assert(false); return 0; } From 91c1355f4674db8fd1e6731d31c92da9f9a87988 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 13 Mar 2024 20:41:31 +0200 Subject: [PATCH 043/120] Tests: fixed formatting --- .../spanbuf/spanbuf.virtuals/seekpos.pass.cpp | 2 +- .../spanstream/inherited.stream.ops.pass.cpp | 38 +++++++------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp index 71594c0066720..a7e9584ed2fd7 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp @@ -164,7 +164,7 @@ void test() { SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.pubseekpos(999, std::ios_base::in) == -1); - + assert(spBuf.pubseekpos(999, std::ios_base::out) == -1); assert(spBuf.pubseekpos(0, std::ios_base::in) == 0); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index febba22eee00b..e0d161d92437f 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -43,7 +43,7 @@ void test() { initialize_array(arr, sv); std::span sp{arr}; - // Mode: default + // Mode: default (`in` | `out`) { SpStream spSt(sp); std::basic_string str1; @@ -76,30 +76,18 @@ void test() { assert(str4 == CS("year")); assert(i4 == 2024); } - // // Mode: `ios_base::in` - // { - // SpStream rhsSpSt{sp, std::ios_base::in}; - // SpStream spSt(std::move(rhsSpSt)); - // assert(spSt.span().data() == arr); - // assert(!spSt.span().empty()); - // assert(spSt.span().size() == 4); - // } - // // Mode `ios_base::out` - // { - // SpStream rhsSpSt{sp, std::ios_base::out}; - // SpStream spSt(std::move(rhsSpSt)); - // assert(spSt.span().data() == arr); - // assert(spSt.span().empty()); - // assert(spSt.span().size() == 0); - // } - // // Mode: multiple - // { - // SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - // SpStream spSt(std::move(rhsSpSt)); - // assert(spSt.span().data() == arr); - // assert(spSt.span().empty()); - // assert(spSt.span().size() == 0); - // } + // Mode: `ios_base::in` + { + SpStream spSt{sp, std::ios_base::in}; + //TODO + (void)spSt; + } + // Mode `ios_base::out` + { + SpStream spSt{sp, std::ios_base::out}; + //TODO + (void)spSt; + } } int main(int, char**) { From c4d1aeee7b6eab051b24b3849c237bd1b351df79 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 11:04:19 +0200 Subject: [PATCH 044/120] Tests: WIP `spanstream` --- .../spanbuf/spanbuf.members/span.pass.cpp | 1 - .../spanbuf.members/span.span.pass.cpp | 1 - .../spanstream/inherited.stream.ops.pass.cpp | 2 +- .../spanstream.cons/assign.move.pass.cpp | 86 +++++++++ .../spanstream.cons/ctor.move.pass.cpp | 86 +++++++++ ....mode.pass.cpp => ctor.span.mode.pass.cpp} | 43 +++-- .../spanstream.members/rdbuf.pass.cpp | 87 +++++++++ .../spanstream.members/span.pass.cpp | 88 +++++++++ .../spanstream.members/span.span.pass.cpp | 171 ++++++++++++++++++ .../swap.pass.cpp} | 27 +-- .../spanstream.swap/swap_nonmember.pass.cpp | 81 +++++++++ 11 files changed, 643 insertions(+), 30 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp rename libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/{span.mode.pass.cpp => ctor.span.mode.pass.cpp} (73%) create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp rename libcxx/test/std/input.output/span.streams/spanstream/{spanstream.cons/move.pass.cpp => spanstream.swap/swap.pass.cpp} (77%) create mode 100644 libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index d868676c18886..bf21a0bc7844c 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -22,7 +22,6 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index e3c836d27e349..3bcfe3ec3ead1 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -23,7 +23,6 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index e0d161d92437f..ab43356a28846 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -12,7 +12,7 @@ // template> // class basic_spanstream -// : public basic_streambuf { +// : public basic_iostream { // Test stream operations inherited from `basic_istream` and `basic_ostream` diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp new file mode 100644 index 0000000000000..f59f975d062ff --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// // [spanstream.cons], constructors + +// basic_spanstream& operator=(basic_spanstream&& rhs); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode `ate` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp new file mode 100644 index 0000000000000..e6367fb667fb6 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// // [spanstream.cons], constructors + +// basic_spanstream(basic_spanstream&& rhs); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_spanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp similarity index 73% rename from libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp rename to libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 122d210430d9f..5a6c7c1c90e2c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -12,15 +12,13 @@ // template> // class basic_spanstream -// : public basic_streambuf { +// : public basic_iostream { -// // [spanbuf.cons], constructors -// +// // [spanstream.cons], constructors // explicit basic_spanstream(std::span s, -// ios_base::openmode which = ios_base::in); +// ios_base::openmode which = ios_base::out | ios_base::in); #include -#include #include #include #include @@ -53,58 +51,71 @@ void test() { CharT arr[4]; std::span sp{arr}; - // Mode: default + // Mode: default (`in` | `out`) { - SpStream spSt(sp); + SpStream spSt{sp}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp)); + SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { - SpStream spSt(sp, std::ios_base::in); + SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt(std::as_const(sp), std::ios_base::in); + SpStream spSt{std::as_const(sp), std::ios_base::in}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { - SpStream spSt(sp, std::ios_base::out); + SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::out); + SpStream spSt{std::as_const(sp), std::ios_base::out}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream spSt(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpStream spSt{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } + // Mode `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + { + SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp new file mode 100644 index 0000000000000..38f998fda05f8 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// // [spanstream.members], members +// basic_spanbuf* rdbuf() const noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_spanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt{sp}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{sp, std::ios_base::in}; + assert(spSt.rdbuf()->span().data() == arr); + assert(!spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 4); + } + // Mode: `out` + { + SpStream spSt{sp, std::ios_base::out}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.rdbuf()->span().data() == arr); + assert(!spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp new file mode 100644 index 0000000000000..96ba53a588e6e --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// // [spanstream.members], members + +// std::span span() const noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_spanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt{sp}; + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{sp, std::ios_base::in}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `out` + { + SpStream spSt{sp, std::ios_base::out}; + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp new file mode 100644 index 0000000000000..2aae1c34a8bb8 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp @@ -0,0 +1,171 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// // [spanstream.members], members + +// void span(std::span s) noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_spanbuf; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + { + SpStream spSt; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(sp); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{std::ios_base::in}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + { + SpStream spSt{std::ios_base::in}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(sp); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `out` + { + SpStream spSt{std::ios_base::out}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + { + SpStream spSt{std::ios_base::out}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(sp); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + { + SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(sp); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + { + SpStream spSt{std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(sp); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp similarity index 77% rename from libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp rename to libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp index 73206597cd27d..6a3e736e34f68 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp @@ -12,11 +12,10 @@ // template> // class basic_spanstream -// : public basic_streambuf { +// : public basic_iostream { -// // [spanbuf.cons], constructors -// -// basic_spanstream(basic_spanstream&& rhs); +// // [spanstream.swap], swap +// void swap(basic_spanstream& rhs); #include #include @@ -29,23 +28,27 @@ template > void test() { - using SpStream = std::basic_spanstream; + using SpStream = std::basic_ispanstream; CharT arr[4]; std::span sp{arr}; + // TODO: + // Mode: default { SpStream rhsSpSt{sp}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode: `ios_base::in` { SpStream rhsSpSt{sp, std::ios_base::in}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); @@ -53,7 +56,8 @@ void test() { // Mode `ios_base::out` { SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -61,7 +65,8 @@ void test() { // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt(std::span{}); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp new file mode 100644 index 0000000000000..5319ca57ce9de --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// void swap(basic_spanstream& x, basic_spanstream& y); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_convertible.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + std::span sp{arr}; + + // TODO: + + // Mode: default + { + SpStream rhsSpSt{sp}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `ios_base::in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode `ios_base::out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt(std::span{}); + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} From 19ec42a3e5d7dd06b5f2ce844dce1f934800fc5f Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 11:40:36 +0200 Subject: [PATCH 045/120] Tests: `spanstream` --- .../ispanstream.assign/move.pass.cpp | 5 +- .../ispanstream.assign/swap.pass.cpp | 4 +- .../swap_nonmember.pass.cpp | 4 +- .../ispanstream.cons/move.pass.cpp | 4 +- .../ispanstream.cons/span.mode.pass.cpp | 4 +- .../ospanstream.cons/move.pass.cpp | 4 +- .../ospanstream.cons/span.mode.pass.cpp | 4 +- .../spanbuf/spanbuf.assign/swap.pass.cpp | 7 +- .../spanbuf.assign/swap_nonmember.pass.cpp | 7 +- .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 6 +- .../spanstream/inherited.stream.ops.pass.cpp | 4 +- .../spanstream/spanstream.swap/swap.pass.cpp | 97 ++++++++++++++++--- .../spanstream.swap/swap_nonmember.pass.cpp | 96 +++++++++++++++--- 13 files changed, 192 insertions(+), 54 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp index 75ae944d01c82..cc14bfb41671e 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp @@ -24,7 +24,6 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > @@ -44,7 +43,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; SpStream spSt = std::move(rhsSpSt); @@ -52,7 +51,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; SpStream spSt = std::move(rhsSpSt); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp index 1aef6a3f47629..c70d9017e53bd 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp @@ -44,7 +44,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; SpStream spSt(std::span{}); @@ -53,7 +53,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; SpStream spSt(std::span{}); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp index 165dc72673e9f..06f59daafac08 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp @@ -40,7 +40,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; SpStream spSt(std::span{}); @@ -49,7 +49,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; SpStream spSt(std::span{}); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp index 2207b773bd9ce..aafcbf6c88961 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp @@ -42,7 +42,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; SpStream spSt(std::move(rhsSpSt)); @@ -50,7 +50,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; SpStream spSt(std::move(rhsSpSt)); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp index 55b2aaf5c3b2b..75691ebc84fc6 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp @@ -66,7 +66,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream spSt(sp, std::ios_base::in); assert(spSt.span().data() == arr); @@ -79,7 +79,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `ios_base::out` + // Mode `out` { SpStream spSt(sp, std::ios_base::out); assert(spSt.span().data() == arr); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp index 43354d6b8dfcb..f361f0489e32f 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp @@ -42,7 +42,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; SpStream spSt(std::move(rhsSpSt)); @@ -50,7 +50,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; SpStream spSt(std::move(rhsSpSt)); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp index fe274e9208c62..3e2a7f1604aa5 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp @@ -66,7 +66,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream spSt(sp, std::ios_base::in); assert(spSt.span().data() == arr); @@ -79,7 +79,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpStream spSt(sp, std::ios_base::out); assert(spSt.span().data() == arr); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index 26b305333e42e..0adbd21a7ee62 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -22,7 +22,6 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > @@ -58,7 +57,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; assert(rhsSpBuf.span().data() == arr); @@ -78,7 +77,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpBuf rhsSpBuf{sp, std::ios_base::out}; assert(rhsSpBuf.span().data() == arr); @@ -122,7 +121,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: `ios_base::ate` + // Mode: `ate` { SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index 681f157553326..cfbd8e9948a57 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -18,7 +18,6 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > @@ -54,7 +53,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; assert(rhsSpBuf.span().data() == arr); @@ -74,7 +73,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpBuf rhsSpBuf{sp, std::ios_base::out}; assert(rhsSpBuf.span().data() == arr); @@ -118,7 +117,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: `ios_base::ate` + // Mode: `ate` { SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index b0d6471097998..254f4cdc40c0c 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -46,7 +46,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpBuf spBuf{sp, std::ios_base::in}; assert(spBuf.span().data() == arr); @@ -58,7 +58,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.span().data() == arr); @@ -86,7 +86,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: `ios_base::ate` + // Mode: `ate` { SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == arr); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index ab43356a28846..a03ff9d257d63 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -76,13 +76,13 @@ void test() { assert(str4 == CS("year")); assert(i4 == 2024); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream spSt{sp, std::ios_base::in}; //TODO (void)spSt; } - // Mode `ios_base::out` + // Mode `out` { SpStream spSt{sp, std::ios_base::out}; //TODO diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp index 6a3e736e34f68..4b29b153664ce 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp @@ -17,59 +17,130 @@ // // [spanstream.swap], swap // void swap(basic_spanstream& rhs); + #include -#include #include #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > void test() { - using SpStream = std::basic_ispanstream; + using SpStream = std::basic_spanstream; CharT arr[4]; - std::span sp{arr}; - // TODO: + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; - SpStream spSt(std::span{}); + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::span{}); + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::span{}); + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp index 5319ca57ce9de..50fd1cab63b7c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp @@ -14,58 +14,128 @@ // void swap(basic_spanstream& x, basic_spanstream& y); #include -#include #include #include #include "constexpr_char_traits.h" -#include "test_convertible.h" #include "test_macros.h" template > void test() { - using SpStream = std::basic_ispanstream; + using SpStream = std::basic_spanstream; CharT arr[4]; - std::span sp{arr}; - // TODO: + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; - SpStream spSt(std::span{}); + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } - // Mode: `ios_base::in` + // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } - // Mode `ios_base::out` + // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::span{}); + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::span{}); + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } } From aa9178f18fae15f7e1fcc1759df3be65816dc7c6 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 11:47:23 +0200 Subject: [PATCH 046/120] Tests: Fix CI --- .../span.streams/spanstream/spanstream.swap/swap.pass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp index 4b29b153664ce..e4169cb581b3b 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp @@ -17,7 +17,6 @@ // // [spanstream.swap], swap // void swap(basic_spanstream& rhs); - #include #include #include From 4e7e72e95b66e95d56146ea50c73eaab997d8c2d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 13:44:47 +0200 Subject: [PATCH 047/120] Tests: tweaks `spanbuf` and `spanstream` --- .../span.streams/spanbuf/spanbuf.assign/swap.pass.cpp | 4 ++++ .../spanbuf/spanbuf.assign/swap_nonmember.pass.cpp | 4 ++++ .../span.streams/spanbuf/spanbuf.members/span.pass.cpp | 4 ++++ .../span.streams/spanbuf/spanbuf.members/span.span.pass.cpp | 4 ++++ .../spanstream/spanstream.cons/assign.move.pass.cpp | 4 ++++ .../spanstream/spanstream.cons/ctor.move.pass.cpp | 4 ++++ .../spanstream/spanstream.cons/ctor.span.mode.pass.cpp | 4 +++- .../span.streams/spanstream/spanstream.members/rdbuf.pass.cpp | 4 ++++ .../span.streams/spanstream/spanstream.members/span.pass.cpp | 4 ++++ .../spanstream/spanstream.members/span.span.pass.cpp | 4 ++++ .../span.streams/spanstream/spanstream.swap/swap.pass.cpp | 4 ++++ .../spanstream/spanstream.swap/swap_nonmember.pass.cpp | 4 ++++ 12 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index 0adbd21a7ee62..0b906c8a6a4fc 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -22,6 +22,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -144,6 +145,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index cfbd8e9948a57..9b9f78928a5af 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -18,6 +18,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -140,6 +141,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index bf21a0bc7844c..3eb51e6076e60 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -22,6 +22,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -76,6 +77,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index 3bcfe3ec3ead1..d02527a6fd3c6 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -23,6 +23,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -160,6 +161,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index f59f975d062ff..7caa7020cb0ff 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -23,6 +23,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -75,6 +76,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index e6367fb667fb6..4878ebcda13df 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -23,6 +23,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -75,6 +76,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 5a6c7c1c90e2c..2a320bf9cca26 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -28,7 +28,6 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../helper_macros.h" #include "../../helper_types.h" template > @@ -124,6 +123,9 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp index 38f998fda05f8..9cc0db4b9dc9a 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp @@ -22,6 +22,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -76,6 +77,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp index 96ba53a588e6e..5eedf9e01d9ec 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp @@ -23,6 +23,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -77,6 +78,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp index 2aae1c34a8bb8..58bdf38166ab7 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp @@ -23,6 +23,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -160,6 +161,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp index e4169cb581b3b..4225e80a4da2f 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp @@ -22,6 +22,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -144,6 +145,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp index 50fd1cab63b7c..baba48cbb1d0b 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp @@ -18,6 +18,7 @@ #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -140,6 +141,9 @@ void test() { } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS From 186ff7770d3e6b58bc57e0ba1d3877e515b466e9 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 18:13:31 +0200 Subject: [PATCH 048/120] Tests: updated `spanstream` and `ospanstream` --- .../ospanstream.cons/assign.move.pass.cpp | 90 ++++++++++ .../{move.pass.cpp => ctor.move.pass.cpp} | 30 ++-- ....mode.pass.cpp => ctor.span.mode.pass.cpp} | 45 +++-- .../ospanstream.members/rdbuf.pass.cpp | 91 ++++++++++ .../ospanstream.members/span.pass.cpp | 92 ++++++++++ .../ospanstream.members/span.span.pass.cpp | 117 +++++++++++++ .../ospanstream.swap/swap.pass.cpp | 159 ++++++++++++++++++ .../ospanstream.swap/swap_nonmember.pass.cpp | 155 +++++++++++++++++ .../spanbuf.members/span.span.pass.cpp | 58 ------- .../spanstream.members/span.span.pass.cpp | 58 ------- 10 files changed, 753 insertions(+), 142 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp rename libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/{move.pass.cpp => ctor.move.pass.cpp} (74%) rename libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/{span.mode.pass.cpp => ctor.span.mode.pass.cpp} (72%) create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp new file mode 100644 index 0000000000000..ead2efb5d6bef --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -0,0 +1,90 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_ostream { + +// // [spanstream.cons], constructors + +// basic_spanstream& operator=(basic_ospanstream&& rhs); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + std::span sp{arr}; + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp similarity index 74% rename from libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp rename to libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index f361f0489e32f..8e1937d6d3c2f 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -12,19 +12,18 @@ // template> // class basic_ospanstream -// : public basic_streambuf { +// : public basic_ostream { + +// // [spanstream.cons], constructors -// // [spanbuf.cons], constructors -// // basic_ospanstream(basic_ospanstream&& rhs); #include -#include #include #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -34,10 +33,10 @@ void test() { CharT arr[4]; std::span sp{arr}; - // Mode: default + // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -45,7 +44,7 @@ void test() { // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -53,7 +52,7 @@ void test() { // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -61,14 +60,25 @@ void test() { // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::move(rhsSpSt)); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } + // Mode `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp similarity index 72% rename from libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp rename to libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp index 3e2a7f1604aa5..6d369945f8537 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp @@ -12,15 +12,13 @@ // template> // class basic_ospanstream -// : public basic_streambuf { +// : public basic_ostream { -// // [spanbuf.cons], constructors -// +// // [spanstream.cons], constructors // explicit basic_ospanstream(std::span s, -// ios_base::openmode which = ios_base::in); +// ios_base::openmode which = ios_base::out | ios_base::in); #include -#include #include #include #include @@ -30,12 +28,11 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../helper_macros.h" #include "../../helper_types.h" template > void test_sfinae() { - using SpStream = std::basic_ispanstream; + using SpStream = std::basic_ospanstream; // Mode static_assert(std::constructible_from, std::ios_base::openmode>); @@ -53,58 +50,71 @@ void test() { CharT arr[4]; std::span sp{arr}; - // Mode: default + // Mode: default (`in` | `out`) { - SpStream spSt(sp); + SpStream spSt{sp}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp)); + SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `in` { - SpStream spSt(sp, std::ios_base::in); + SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::in); + SpStream spSt{std::as_const(sp), std::ios_base::in}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode `out` { - SpStream spSt(sp, std::ios_base::out); + SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::out); + SpStream spSt{std::as_const(sp), std::ios_base::out}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream spSt(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpStream spSt{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } + // Mode `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + { + SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } } int main(int, char**) { @@ -113,6 +123,9 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp new file mode 100644 index 0000000000000..fac9df7c7d913 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_ostream { + +// // [ospanstream.members], members +// basic_spanbuf* rdbuf() const noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt{sp}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{sp, std::ios_base::in}; + assert(spSt.rdbuf()->span().data() == arr); + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `out` + { + SpStream spSt{sp, std::ios_base::out}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.rdbuf()->span().data() == arr); + assert(!spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp new file mode 100644 index 0000000000000..f92ed56c53b6d --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_ostream { + +// // [ospanstream.members], members + +// std::span span() const noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt{sp}; + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{sp, std::ios_base::in}; + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `out` + { + SpStream spSt{sp, std::ios_base::out}; + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp new file mode 100644 index 0000000000000..45411696e0d68 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp @@ -0,0 +1,117 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// // [spanstream.members], members + +// void span(std::span s) noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_spanbuf; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{std::ios_base::in}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `out` + { + SpStream spSt{std::ios_base::out}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp new file mode 100644 index 0000000000000..e6a7d2d457e20 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp @@ -0,0 +1,159 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_ostream { + +// // [spanstream.swap], swap +// void swap(basic_ospanstream& rhs); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp new file mode 100644 index 0000000000000..fc3f9a57afcf5 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp @@ -0,0 +1,155 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// void swap(basic_ospanstream& x, basic_ospanstream& y); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index d02527a6fd3c6..510b5f9d70f4c 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -50,18 +50,6 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - { - SpBuf spBuf; - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - - spBuf.span(sp); - assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } // Mode: `in` { SpBuf spBuf{std::ios_base::in}; @@ -74,17 +62,6 @@ void test() { assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } - { - SpBuf spBuf{std::ios_base::in}; - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - - spBuf.span(sp); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } // Mode: `out` { SpBuf spBuf{std::ios_base::out}; @@ -98,18 +75,6 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - { - SpBuf spBuf{std::ios_base::out}; - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - - spBuf.span(sp); - assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } // Mode: multiple { SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); @@ -123,18 +88,6 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - { - SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - - spBuf.span(sp); - assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } // Mode: `ate` { SpBuf spBuf(std::ios_base::out | std::ios_base::ate); @@ -147,17 +100,6 @@ void test() { assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } - { - SpBuf spBuf(std::ios_base::out | std::ios_base::ate); - assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - - spBuf.span(sp); - assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); - assert(spBuf.span().size() == 4); - } } int main(int, char**) { diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp index 58bdf38166ab7..45411696e0d68 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp @@ -50,18 +50,6 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - { - SpStream spSt; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(sp); - assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } // Mode: `in` { SpStream spSt{std::ios_base::in}; @@ -74,17 +62,6 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - { - SpStream spSt{std::ios_base::in}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(sp); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } // Mode: `out` { SpStream spSt{std::ios_base::out}; @@ -98,18 +75,6 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - { - SpStream spSt{std::ios_base::out}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(sp); - assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } // Mode: multiple { SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; @@ -123,18 +88,6 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - { - SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(sp); - assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } // Mode: `ate` { SpStream spSt{std::ios_base::out | std::ios_base::ate}; @@ -147,17 +100,6 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - { - SpStream spSt{std::ios_base::out | std::ios_base::ate}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(sp); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } } int main(int, char**) { From c82d2c87f7d356f7eac8e9b207269a4b648af53c Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 18:54:15 +0200 Subject: [PATCH 049/120] Tests: updated `ospanstream`, `spanbuf`, `spanstream` --- .../ospanstream.cons/assign.move.pass.cpp | 45 +++++++++++++++++++ .../ospanstream.cons/ctor.move.pass.cpp | 41 +++++++++++++++++ .../{move.pass.cpp => assign.move.pass.cpp} | 0 .../spanbuf/spanbuf.cons/mode.pass.cpp | 9 ++-- .../spanbuf/spanbuf.cons/move.pass.cpp | 25 ++++++----- .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 40 ++++++++--------- .../spanstream.cons/assign.move.pass.cpp | 45 +++++++++++++++++++ .../spanstream.cons/ctor.move.pass.cpp | 45 +++++++++++++++++++ 8 files changed, 215 insertions(+), 35 deletions(-) rename libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/{move.pass.cpp => assign.move.pass.cpp} (100%) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index ead2efb5d6bef..8dd4eab2c86f5 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -36,42 +36,87 @@ void test() { // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index 8e1937d6d3c2f..cdd625529264e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -36,26 +36,53 @@ void test() { // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { @@ -64,14 +91,28 @@ void test() { assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp similarity index 100% rename from libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/move.pass.cpp rename to libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index 91fc5385484f7..4acc5d7d862ba 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -49,14 +49,14 @@ void test() { // Mode: `in` { - SpBuf spBuf(std::ios_base::in); + SpBuf spBuf{std::ios_base::in}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `out` { - SpBuf spBuf(std::ios_base::out); + SpBuf spBuf{std::ios_base::out}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -64,7 +64,7 @@ void test() { } // Mode: multiple { - SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read character assert(spBuf.span().empty()); @@ -72,9 +72,8 @@ void test() { } // Mode: `ate` { - SpBuf spBuf(std::ios_base::out | std::ios_base::ate); + SpBuf spBuf{std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index e9e483d290c55..d094c491ca45e 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -164,7 +164,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -183,7 +183,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); @@ -201,7 +201,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -221,7 +221,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -235,7 +235,7 @@ void test() { // Mode: `ate` { SpBuf rhsSpBuf{std::ios_base::ate}; - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); @@ -260,7 +260,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -278,10 +278,15 @@ void test() { assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); + + // After move + assert(rhsSpBuf.span().data() == arr); + assert(!rhsSpBuf.span().empty()); + assert(rhsSpBuf.span().size() == 4); } // Mode `out` { @@ -291,7 +296,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -310,7 +315,7 @@ void test() { assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -328,7 +333,7 @@ void test() { assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); - SpBuf spBuf(std::move(rhsSpBuf)); + SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index 9557b096f8f91..c719c9caa9865 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -55,14 +55,14 @@ void test() { // Mode: default (`in` | `out`) { - SpBuf spBuf(sp); + SpBuf spBuf{sp}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp)); + SpBuf spBuf{std::as_const(sp)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -70,27 +70,27 @@ void test() { } // Mode: `in` { - SpBuf spBuf(sp, std::ios_base::in); + SpBuf spBuf{sp, std::ios_base::in}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::in); + SpBuf spBuf{std::as_const(sp), std::ios_base::in}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `out` { - SpBuf spBuf(sp, std::ios_base::out); + SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::out); + SpBuf spBuf{std::as_const(sp), std::ios_base::out}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -98,14 +98,14 @@ void test() { } // Mode: multiple { - SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -113,13 +113,13 @@ void test() { } // Mode: `ate` { - SpBuf spBuf(sp, std::ios_base::out | std::ios_base::ate); + SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::out | std::ios_base::ate); + SpBuf spBuf{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); @@ -133,14 +133,14 @@ void test() { // Mode: default (`in` | `out`) { - SpBuf spBuf(sp); + SpBuf spBuf{sp}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp)); + SpBuf spBuf{std::as_const(sp)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -148,27 +148,27 @@ void test() { } // Mode: `in` { - SpBuf spBuf(sp, std::ios_base::in); + SpBuf spBuf{sp, std::ios_base::in}; assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::in); + SpBuf spBuf{std::as_const(sp), std::ios_base::in}; assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } // Mode `out` { - SpBuf spBuf(sp, std::ios_base::out); + SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::out); + SpBuf spBuf{std::as_const(sp), std::ios_base::out}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -176,14 +176,14 @@ void test() { } // Mode: multiple { - SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters assert(spBuf.span().empty()); @@ -191,13 +191,13 @@ void test() { } // Mode: `ate` { - SpBuf spBuf(sp, std::ios_base::out | std::ios_base::ate); + SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } { - SpBuf spBuf(std::as_const(sp), std::ios_base::out | std::ios_base::ate); + SpBuf spBuf{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == arr); assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index 7caa7020cb0ff..ac807b405b18a 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -36,42 +36,87 @@ void test() { // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index 4878ebcda13df..87ef4c06a8ff8 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -36,42 +36,87 @@ void test() { // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } } From 6315328532fea59319f0118a1e658f26801ae4e2 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 20:50:19 +0200 Subject: [PATCH 050/120] Tests: updated and fixed tests --- .../ispanstream.assign/swap.pass.cpp | 85 ---------- .../swap_nonmember.pass.cpp | 81 --------- .../ispanstream.cons/assign.move.pass.cpp | 140 ++++++++++++++++ .../{move.pass.cpp => ctor.move.pass.cpp} | 70 +++++++- .../{ros.pass.cpp => ctor.ros.pass.cpp} | 6 +- ....mode.pass.cpp => ctor.span.mode.pass.cpp} | 43 +++-- .../ispanstream.members/rdbuf.pass.cpp | 91 ++++++++++ .../span.pass.cpp} | 43 +++-- .../ispanstream.members/span.span.pass.cpp | 116 +++++++++++++ .../ispanstream.swap/swap.pass.cpp | 155 ++++++++++++++++++ .../ispanstream.swap/swap_nonmember.pass.cpp | 153 +++++++++++++++++ .../ospanstream.cons/assign.move.pass.cpp | 4 + .../ospanstream.cons/ctor.move.pass.cpp | 8 + .../ospanstream.cons/ctor.span.mode.pass.cpp | 5 + .../ospanstream.members/span.span.pass.cpp | 20 +-- .../ospanstream.swap/swap.pass.cpp | 2 +- .../spanstream.cons/assign.move.pass.cpp | 18 +- .../spanstream.cons/ctor.move.pass.cpp | 4 + .../spanstream.cons/ctor.span.mode.pass.cpp | 6 +- .../spanstream.members/span.span.pass.cpp | 12 +- 20 files changed, 836 insertions(+), 226 deletions(-) delete mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp delete mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp rename libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/{move.pass.cpp => ctor.move.pass.cpp} (51%) rename libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/{ros.pass.cpp => ctor.ros.pass.cpp} (95%) rename libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/{span.mode.pass.cpp => ctor.span.mode.pass.cpp} (73%) create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp rename libcxx/test/std/input.output/span.streams/ispanstream/{ispanstream.assign/move.pass.cpp => ispanstream.members/span.pass.cpp} (65%) create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp deleted file mode 100644 index c70d9017e53bd..0000000000000 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap.pass.cpp +++ /dev/null @@ -1,85 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 - -// - -// template> -// class basic_ispanstream -// : public basic_streambuf { - -// // [ispanstream.swap], swap -// void swap(basic_ispanstream& rhs); - -#include -#include -#include -#include - -#include "constexpr_char_traits.h" -#include "test_convertible.h" -#include "test_macros.h" - -template > -void test() { - using SpStream = std::basic_ispanstream; - - CharT arr[4]; - std::span sp{arr}; - - // TODO: - - // Mode: default - { - SpStream rhsSpSt{sp}; - SpStream spSt(std::span{}); - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: `in` - { - SpStream rhsSpSt{sp, std::ios_base::in}; - SpStream spSt(std::span{}); - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode `out` - { - SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::span{}); - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::span{}); - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } -} - -int main(int, char**) { - test(); - test>(); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); - test>(); -#endif - - return 0; -} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp deleted file mode 100644 index 06f59daafac08..0000000000000 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/swap_nonmember.pass.cpp +++ /dev/null @@ -1,81 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 - -// - -// template -// void swap(basic_ispanstream& x, basic_ispanstream& y); - -#include -#include -#include -#include - -#include "constexpr_char_traits.h" -#include "test_convertible.h" -#include "test_macros.h" - -template > -void test() { - using SpStream = std::basic_ispanstream; - - CharT arr[4]; - std::span sp{arr}; - - // TODO: - - // Mode: default - { - SpStream rhsSpSt{sp}; - SpStream spSt(std::span{}); - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: `in` - { - SpStream rhsSpSt{sp, std::ios_base::in}; - SpStream spSt(std::span{}); - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode `out` - { - SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::span{}); - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::span{}); - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } -} - -int main(int, char**) { - test(); - test>(); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); - test>(); -#endif - - return 0; -} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp new file mode 100644 index 0000000000000..bba20cd973141 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_istream { + +// // [spanbuf.cons], constructors +// +// basic_ispanstream& operator=(basic_ispanstream&& rhs); + +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt = std::move(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp similarity index 51% rename from libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp rename to libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp index aafcbf6c88961..8ed9f0aba190e 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp @@ -12,7 +12,7 @@ // template> // class basic_ispanstream -// : public basic_streambuf { +// : public basic_istream { // // [spanbuf.cons], constructors // @@ -24,7 +24,7 @@ #include #include "constexpr_char_traits.h" -#include "test_convertible.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -32,43 +32,103 @@ void test() { using SpStream = std::basic_ispanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt(std::move(rhsSpSt)); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + SpStream spSt(std::move(rhsSpSt)); assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt(std::move(rhsSpSt)); + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt(std::move(rhsSpSt)); + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt{std::move(rhsSpSt)}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + + // After move + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp similarity index 95% rename from libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp rename to libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index ac64e66725f15..5cec1de19ffb1 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -12,7 +12,7 @@ // template> // class basic_ispanstream -// : public basic_streambuf { +// : public basic_istream { // // [spanbuf.cons], constructors // @@ -56,6 +56,7 @@ void test() { // TODO: CharT arr[4]; + ReadOnlySpan ros{arr}; { @@ -83,6 +84,9 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp similarity index 73% rename from libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp rename to libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index 75691ebc84fc6..81e544da3c263 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -12,9 +12,9 @@ // template> // class basic_ispanstream -// : public basic_streambuf { +// : public basic_istream { -// // [spanbuf.cons], constructors +// // [ispanstream.cons], constructors // // explicit basic_ispanstream(std::span s, // ios_base::openmode which = ios_base::in); @@ -30,7 +30,6 @@ #include "test_convertible.h" #include "test_macros.h" -#include "../../helper_macros.h" #include "../../helper_types.h" template > @@ -51,60 +50,77 @@ void test() { using SpStream = std::basic_ispanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { - SpStream spSt(sp); + SpStream spSt{sp}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt(std::as_const(sp)); + SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: `in` { - SpStream spSt(sp, std::ios_base::in); + SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt(std::as_const(sp), std::ios_base::in); + SpStream spSt{std::as_const(sp), std::ios_base::in}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode `out` { - SpStream spSt(sp, std::ios_base::out); + SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::out); + SpStream spSt{std::as_const(sp), std::ios_base::out}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream spSt(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { - SpStream spSt(std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpStream spSt{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } + // Mode `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + { + SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } } int main(int, char**) { @@ -113,6 +129,9 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp new file mode 100644 index 0000000000000..0b5aa94f1b88a --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ospanstream +// : public basic_istream { + +// // [ospanstream.members], members +// basic_spanbuf* rdbuf() const noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt{sp}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `in` + { + SpStream spSt{sp, std::ios_base::in}; + assert(spSt.rdbuf()->span().data() == arr); + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `out` + { + SpStream spSt{sp, std::ios_base::out}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.rdbuf()->span().data() == arr); + // Mode `out` counts read characters + assert(spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.rdbuf()->span().data() == arr); + assert(!spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp similarity index 65% rename from libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp rename to libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp index cc14bfb41671e..e1b6734301e06 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.assign/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp @@ -12,18 +12,18 @@ // template> // class basic_ispanstream -// : public basic_streambuf { +// : public basic_istream { -// // [spanbuf.cons], constructors -// -// basic_ispanstream& operator=(basic_ispanstream&& rhs); +// // [ispanstream.members], members + +// std::span span() const noexcept; #include -#include #include #include #include "constexpr_char_traits.h" +#include "nasty_string.h" #include "test_macros.h" template > @@ -31,45 +31,54 @@ void test() { using SpStream = std::basic_ispanstream; CharT arr[4]; - std::span sp{arr}; - // TODO: + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); - // Mode: default + // Mode: default (`in` | `out`) { - SpStream rhsSpSt{sp}; - SpStream spSt = std::move(rhsSpSt); + SpStream spSt{sp}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: `in` { - SpStream rhsSpSt{sp, std::ios_base::in}; - SpStream spSt = std::move(rhsSpSt); + SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `out` + // Mode: `out` { - SpStream rhsSpSt{sp, std::ios_base::out}; - SpStream spSt = std::move(rhsSpSt); + SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - SpStream spSt = std::move(rhsSpSt); + SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); } + // Mode: `ate` + { + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } } int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp new file mode 100644 index 0000000000000..8603e0b87c9f7 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp @@ -0,0 +1,116 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_istream { + +// // [ispanstream.members], members + +// void span(std::span s) noexcept; + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `in` + { + SpStream spSt{std::span{}, std::ios_base::in}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + // Mode: `out` + { + SpStream spSt{std::span{}, std::ios_base::out}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: multiple + { + SpStream spSt{std::span{}, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream spSt{std::span{}, std::ios_base::out | std::ios_base::ate}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.span(arr); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp new file mode 100644 index 0000000000000..d0abcb6b2b6d1 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp @@ -0,0 +1,155 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_ispanstream +// : public basic_istream { + +// // [ispanstream.swap], swap +// void swap(basic_ispanstream& rhs); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + spSt.swap(rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp new file mode 100644 index 0000000000000..9b8f32d1f08b0 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp @@ -0,0 +1,153 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template +// void swap(basic_ispanstream& x, basic_ispanstream& y); + +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "nasty_string.h" +#include "test_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + CharT arr[4]; + + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); + + // Mode: default (`in` | `out`) + { + SpStream rhsSpSt{sp}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `in` + { + SpStream rhsSpSt{sp, std::ios_base::in}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode `out` + { + SpStream rhsSpSt{sp, std::ios_base::out}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: multiple + { + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + + SpStream spSt{std::span{}}; + assert(spSt.span().data() == nullptr); + // Mode `out` counts read characters + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } + // Mode: `ate` + { + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + assert(rhsSpSt.span().data() == arr); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); + + SpStream spSt(std::span{}); + assert(spSt.span().data() == nullptr); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); + + std::swap(spSt, rhsSpSt); + assert(spSt.span().data() == arr); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + assert(rhsSpSt.span().data() == nullptr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + } +} + +int main(int, char**) { +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 8dd4eab2c86f5..2b9c3a38dea85 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -31,7 +31,11 @@ void test() { using SpStream = std::basic_ospanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); // Mode: default (`in` | `out`) { diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index cdd625529264e..3c543397e4523 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -31,7 +31,11 @@ void test() { using SpStream = std::basic_ospanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); // Mode: default (`in` | `out`) { @@ -87,6 +91,10 @@ void test() { // Mode: multiple { SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + assert(rhsSpSt.span().data() == arr); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); + SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); assert(spSt.span().empty()); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp index 6d369945f8537..bc70fb4a440a7 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp @@ -19,6 +19,7 @@ // ios_base::openmode which = ios_base::out | ios_base::in); #include +#include #include #include #include @@ -48,7 +49,11 @@ void test() { using SpStream = std::basic_ospanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); // Mode: default (`in` | `out`) { diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp index 45411696e0d68..fab565d97a286 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp @@ -11,8 +11,8 @@ // // template> -// class basic_spanstream -// : public basic_iostream { +// class basic_ospanstream +// : public basic_ostream { // // [spanstream.members], members @@ -28,7 +28,7 @@ template > void test() { - using SpStream = std::basic_spanbuf; + using SpStream = std::basic_ospanstream; CharT arr[4]; @@ -39,7 +39,7 @@ void test() { // Mode: default (`in` | `out`) { - SpStream spSt; + SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -52,19 +52,19 @@ void test() { } // Mode: `in` { - SpStream spSt{std::ios_base::in}; + SpStream spSt{std::span{}, std::ios_base::in}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); } // Mode: `out` { - SpStream spSt{std::ios_base::out}; + SpStream spSt{std::span{}, std::ios_base::out}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -77,7 +77,7 @@ void test() { } // Mode: multiple { - SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::span{}, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -90,7 +90,7 @@ void test() { } // Mode: `ate` { - SpStream spSt{std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::span{}, std::ios_base::out | std::ios_base::ate}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp index e6a7d2d457e20..9521118f27e3e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp @@ -14,7 +14,7 @@ // class basic_ospanstream // : public basic_ostream { -// // [spanstream.swap], swap +// // [ospanstream.swap], swap // void swap(basic_ospanstream& rhs); #include diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index ac807b405b18a..2a1229445ac7e 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -28,27 +28,31 @@ template > void test() { - using SpStream = std::basic_ispanstream; + using SpStream = std::basic_spanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); + assert(spSt.span().empty()); + assert(spSt.span().size() == 0); // After move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); + assert(rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 0); } // Mode: `in` { diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index 87ef4c06a8ff8..b70e6bf4c6b9c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -31,7 +31,11 @@ void test() { using SpStream = std::basic_spanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); // Mode: default (`in` | `out`) { diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 2a320bf9cca26..f0cab5c464617 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -32,7 +32,7 @@ template > void test_sfinae() { - using SpStream = std::basic_ispanstream; + using SpStream = std::basic_spanstream; // Mode static_assert(std::constructible_from, std::ios_base::openmode>); @@ -48,7 +48,11 @@ void test() { using SpStream = std::basic_spanstream; CharT arr[4]; + std::span sp{arr}; + assert(sp.data() == arr); + assert(!sp.empty()); + assert(sp.size() == 4); // Mode: default (`in` | `out`) { diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp index 45411696e0d68..77ac8dbfaa2e4 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp @@ -28,7 +28,7 @@ template > void test() { - using SpStream = std::basic_spanbuf; + using SpStream = std::basic_spanstream; CharT arr[4]; @@ -39,7 +39,7 @@ void test() { // Mode: default (`in` | `out`) { - SpStream spSt; + SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -52,7 +52,7 @@ void test() { } // Mode: `in` { - SpStream spSt{std::ios_base::in}; + SpStream spSt{std::span{}, std::ios_base::in}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -64,7 +64,7 @@ void test() { } // Mode: `out` { - SpStream spSt{std::ios_base::out}; + SpStream spSt{std::span{}, std::ios_base::out}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -77,7 +77,7 @@ void test() { } // Mode: multiple { - SpStream spSt{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::span{}, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -90,7 +90,7 @@ void test() { } // Mode: `ate` { - SpStream spSt{std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::span{}, std::ios_base::out | std::ios_base::ate}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); From 5b11364005006f938ff1ef8841d59b79a315709b Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 20:59:03 +0200 Subject: [PATCH 051/120] Tests: fixed CI --- .../span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index 5cec1de19ffb1..005e4a60f3d09 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -56,7 +56,7 @@ void test() { // TODO: CharT arr[4]; - + ReadOnlySpan ros{arr}; { From b2ee7286ceb0d8302947b045050707164e667a16 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 21:07:56 +0200 Subject: [PATCH 052/120] Tests: fixed CI --- .../spanstream/spanstream.cons/ctor.span.mode.pass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index f0cab5c464617..3276a2a25dadc 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -48,7 +48,7 @@ void test() { using SpStream = std::basic_spanstream; CharT arr[4]; - + std::span sp{arr}; assert(sp.data() == arr); assert(!sp.empty()); From 5d13308b9fd5898978df15060a3b1a68d9b66f08 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 15 Mar 2024 23:15:44 +0200 Subject: [PATCH 053/120] Tests: updated `inherited.stream.ops.pass.cpp` --- libcxx/include/spanstream | 2 +- .../spanstream/inherited.stream.ops.pass.cpp | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 2b4b6b79d86fd..cac38447125d2 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -418,7 +418,7 @@ public: // [spanstream.swap], swap - void swap(basic_spanstream& __rhs) { + _LIBCPP_HIDE_FROM_ABI void swap(basic_spanstream& __rhs) { basic_iostream<_CharT, _Traits>::swap(__rhs); __sb_.swap(__rhs.__sb_); } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index a03ff9d257d63..8e529c63cf6de 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -38,14 +38,22 @@ template > void test() { using SpStream = std::basic_spanstream; + constexpr auto arrSize{30UZ}; + constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; - CharT arr[sv.size() + 1]; + assert(sv.size() < arrSize); + + CharT arr[arrSize]{}; initialize_array(arr, sv); + std::span sp{arr}; // Mode: default (`in` | `out`) { SpStream spSt(sp); + assert(spSt.span().size() == 0); + + // Read from stream std::basic_string str1; spSt >> str1; int i1; @@ -66,7 +74,12 @@ void test() { assert(str3 == CS("pir")); assert(i3 == 43); - spSt << CS("year 2024"); + // Write to stream + constexpr std::basic_string_view sv1{SV("year 2024")}; + spSt << sv1; + assert(spSt.span().size() == sv1.size()); + + // Read from stream spSt.seekg(0); std::basic_string str4; spSt >> str4; @@ -75,6 +88,18 @@ void test() { assert(str4 == CS("year")); assert(i4 == 2024); + + // Write to stream + spSt << CS("94"); + spSt << 84; + std::cout << spSt.span().size() << std::endl; + assert(spSt.span().size() == sv1.size() + 4); + + // Write to stream with overflow + constexpr std::basic_string_view sv2{ + SV("This string should overflow! This string should overflow!")}; + spSt << sv2; + assert(spSt.span().size() == arrSize); } // Mode: `in` { From 9decf935e456f5e6ccb1e8adde10cfd7a9d35958 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 16 Mar 2024 12:48:53 +0200 Subject: [PATCH 054/120] Tests: updated `inherited.stream.ops.pass.cpp` --- .../spanstream/inherited.stream.ops.pass.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index 8e529c63cf6de..2cc754fbd3f6e 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -67,6 +67,7 @@ void test() { int i3; spSt >> i3; + assert(spSt.good()); assert(str1 == CS("zmt")); assert(i1 == 94); assert(str2 == CS("hkt")); @@ -77,7 +78,9 @@ void test() { // Write to stream constexpr std::basic_string_view sv1{SV("year 2024")}; spSt << sv1; + assert(spSt.span().size() == sv1.size()); + assert(spSt.good()); // Read from stream spSt.seekg(0); @@ -89,17 +92,28 @@ void test() { assert(str4 == CS("year")); assert(i4 == 2024); + spSt >> i4; + assert(spSt.fail()); + spSt.clear(); + assert(spSt.good()); + // Write to stream spSt << CS("94"); spSt << 84; - std::cout << spSt.span().size() << std::endl; + + assert(spSt.good()); assert(spSt.span().size() == sv1.size() + 4); + std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr1 == CS("year 20249484")); // Write to stream with overflow constexpr std::basic_string_view sv2{ SV("This string should overflow! This string should overflow!")}; spSt << sv2; assert(spSt.span().size() == arrSize); + std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr2 == CS("year 20249484This string shoul")); + assert(spSt.fail()); } // Mode: `in` { From 9d1665a1ce7b1f18afcc8478e21e1f6d21b30087 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 17 Mar 2024 14:09:21 +0200 Subject: [PATCH 055/120] Tests: `stream.ops.pass.cpp` --- .../spanstream/inherited.stream.ops.pass.cpp | 181 +++++++++++++++++- 1 file changed, 175 insertions(+), 6 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index 2cc754fbd3f6e..0744e7e4e47e9 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -51,6 +51,11 @@ void test() { // Mode: default (`in` | `out`) { SpStream spSt(sp); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); assert(spSt.span().size() == 0); // Read from stream @@ -67,7 +72,6 @@ void test() { int i3; spSt >> i3; - assert(spSt.good()); assert(str1 == CS("zmt")); assert(i1 == 94); assert(str2 == CS("hkt")); @@ -75,11 +79,19 @@ void test() { assert(str3 == CS("pir")); assert(i3 == 43); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + // Write to stream constexpr std::basic_string_view sv1{SV("year 2024")}; spSt << sv1; assert(spSt.span().size() == sv1.size()); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); assert(spSt.good()); // Read from stream @@ -93,15 +105,28 @@ void test() { assert(i4 == 2024); spSt >> i4; + + assert(!spSt); + assert(!spSt.bad()); assert(spSt.fail()); + assert(!spSt.good()); + spSt.clear(); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); assert(spSt.good()); // Write to stream spSt << CS("94"); spSt << 84; + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); assert(spSt.good()); + assert(spSt.span().size() == sv1.size() + 4); std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; assert(expectedStr1 == CS("year 20249484")); @@ -113,20 +138,164 @@ void test() { assert(spSt.span().size() == arrSize); std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; assert(expectedStr2 == CS("year 20249484This string shoul")); + + assert(!spSt); + assert(spSt.bad()); assert(spSt.fail()); + assert(!spSt.good()); } +#if 0 // Mode: `in` { SpStream spSt{sp, std::ios_base::in}; - //TODO - (void)spSt; - } + assert(spSt); + assert(spSt.good()); + assert(spSt.span().size() == arrSize); + + std::basic_string expectedStr0{spSt.span().data(), std::size_t{spSt.span().size()}}; + std::cout << expectedStr0 << std::endl; + + // // Read from stream + // std::basic_string str1; + // spSt >> str1; + // int i1; + // spSt >> i1; + // std::basic_string str2; + // spSt >> str2; + // int i2; + // spSt >> i2; + // std::basic_string str3; + // spSt >> str3; + // int i3; + // spSt >> i3; + + // assert(spSt.good()); + // assert(str1 == CS("zmt")); + // assert(i1 == 94); + // assert(str2 == CS("hkt")); + // assert(i2 == 82); + // assert(str3 == CS("pir")); + // assert(i3 == 43); + + // Write to stream + constexpr std::basic_string_view sv1{SV("year 2024")}; + spSt << sv1; + + std::cout << spSt.span().size() << std::endl; + assert(spSt.span().size() == sv1.size()); + assert(spSt.good()); + + // Read from stream + spSt.seekg(0); + std::basic_string str4; + spSt >> str4; + int i4; + spSt >> i4; + + assert(str4 == CS("year")); + assert(i4 == 2024); + + spSt >> i4; + assert(spSt); + assert(!spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); + + spSt.clear(); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + // Write to stream + spSt << CS("94"); + spSt << 84; + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); assert(spSt.span().size() == sv1.size() + 4); + std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr1 == CS("year 20249484")); + + // Write to stream with overflow + constexpr std::basic_string_view sv2{ + SV("This string should overflow! This string should overflow!")}; + spSt << sv2; + assert(spSt.span().size() == arrSize); + std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr2 == CS("year 20249484This string shoul")); + assert(spSt); + assert(!spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); } // Mode `out` { SpStream spSt{sp, std::ios_base::out}; - //TODO - (void)spSt; + assert(spSt.span().size() == 0); + + // Read from stream + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + int i3; + spSt >> i3; + + assert(spSt.good()); + assert(str1 == CS("zmt")); + assert(i1 == 94); + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + assert(i3 == 43); + + // Write to stream + constexpr std::basic_string_view sv1{SV("year 2024")}; + spSt << sv1; + + assert(spSt.span().size() == sv1.size()); + assert(spSt.good()); + + // Read from stream + spSt.seekg(0); + std::basic_string str4; + spSt >> str4; + int i4; + spSt >> i4; + + assert(str4 == CS("year")); + assert(i4 == 2024); + + spSt >> i4; + assert(spSt.fail()); + spSt.clear(); + assert(spSt.good()); + + // Write to stream + spSt << CS("94"); + spSt << 84; + + assert(spSt.good()); + assert(spSt.span().size() == sv1.size() + 4); + std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr1 == CS("year 20249484")); + + // Write to stream with overflow + constexpr std::basic_string_view sv2{ + SV("This string should overflow! This string should overflow!")}; + spSt << sv2; + assert(spSt.span().size() == arrSize); + std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr2 == CS("year 20249484This string shoul")); + assert(spSt.fail()); } +#endif } int main(int, char**) { From 21be2dc8fce54db1afccfc06940e5ee30b5cd09d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 19 Jul 2024 19:15:42 +0300 Subject: [PATCH 056/120] Updated Release Notes --- libcxx/docs/FeatureTestMacroTable.rst | 2 +- libcxx/docs/ReleaseNotes/20.rst | 1 + libcxx/docs/Status/Cxx23Papers.csv | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index 61805726a4ff0..5f8151d241b49 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -394,7 +394,7 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_reference_from_temporary`` *unimplemented* ---------------------------------------------------------- ----------------- - ``__cpp_lib_spanstream`` *unimplemented* + ``__cpp_lib_spanstream`` ``202106L`` ---------------------------------------------------------- ----------------- ``__cpp_lib_stacktrace`` *unimplemented* ---------------------------------------------------------- ----------------- diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst index 572d4321dc46f..7561e51a3a36a 100644 --- a/libcxx/docs/ReleaseNotes/20.rst +++ b/libcxx/docs/ReleaseNotes/20.rst @@ -45,6 +45,7 @@ Implemented Papers - P2609R3: Relaxing Ranges Just A Smidge (`Github `__) - P2985R0: A type trait for detecting virtual base classes (`Github `__) - ``std::jthread`` and ```` are not guarded behind ``-fexperimental-library`` anymore +- P0448R4 - A ``strstream`` replacement using ``span`` as buffer - P2674R1: A trait for implicit lifetime types (`Github `__) - P0429R9: A Standard ``flat_map`` (`Github `__) diff --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv index e4fa07d82289d..f7d087c499da8 100644 --- a/libcxx/docs/Status/Cxx23Papers.csv +++ b/libcxx/docs/Status/Cxx23Papers.csv @@ -12,7 +12,7 @@ "`P2259R1 `__","Repairing input range adaptors and counted_iterator","2021-02 (Virtual)","","","" "","","","","","" "`P0401R6 `__","Providing size feedback in the Allocator interface","2021-06 (Virtual)","|Complete|","15","" -"`P0448R4 `__","A strstream replacement using span as buffer","2021-06 (Virtual)","","","" +"`P0448R4 `__","A ``strstream`` replacement using ``span`` as buffer","June 2021","|Complete|","21" "`P1132R8 `__","out_ptr - a scalable output pointer abstraction","2021-06 (Virtual)","|Complete|","19","" "`P1328R1 `__","Making std::type_info::operator== constexpr","2021-06 (Virtual)","|Complete|","17","" "`P1425R4 `__","Iterators pair constructors for stack and queue","2021-06 (Virtual)","|Complete|","14","" From 4143152c0d70d03500d1c58e9b9480622715b86f Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 19 Jul 2024 19:33:54 +0300 Subject: [PATCH 057/120] Removed #include <__availability> --- libcxx/include/spanstream | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index cac38447125d2..3af5b58ee615d 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -55,7 +55,6 @@ // clang-format on #include <__assert> // all public C++ headers provide the assertion handler -#include <__availability> #include <__concepts/convertible_to.h> #include <__config> #include <__fwd/spanstream.h> From 09781e473b113b701d275edbcdaaa189ec2dea5b Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 19 Jul 2024 19:35:13 +0300 Subject: [PATCH 058/120] Removed #include <__assert> --- libcxx/include/spanstream | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 3af5b58ee615d..e1d6765e78a51 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -54,7 +54,6 @@ // clang-format on -#include <__assert> // all public C++ headers provide the assertion handler #include <__concepts/convertible_to.h> #include <__config> #include <__fwd/spanstream.h> From 574b727cd7ba41235aa983720ae203eaa9535ff4 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 3 Aug 2024 17:14:59 +0300 Subject: [PATCH 059/120] Updated: libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp --- .../ispanstream.cons/assign.move.pass.cpp | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp index bba20cd973141..9c893e32e614b 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -38,7 +38,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -72,43 +72,26 @@ void test() { assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode `out` + // Mode: multiple (`in` | `binary`) { - SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt = std::move(rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - // After move - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); // After move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } - // Mode `ate` + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -136,5 +119,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From 9f863ed1e6f7d8fdae08b07efee2469d66827666 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 3 Aug 2024 23:38:49 +0300 Subject: [PATCH 060/120] Updated: libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp --- .../ispanstream.cons/assign.move.pass.cpp | 16 +++--- .../ispanstream.cons/ctor.move.pass.cpp | 54 ++++++++----------- .../ospanstream.cons/assign.move.pass.cpp | 10 ++-- .../ospanstream.cons/ctor.move.pass.cpp | 10 ++-- .../spanbuf.assign/assign.move.pass.cpp | 18 +++---- .../spanbuf/spanbuf.cons/move.pass.cpp | 20 +++---- .../spanstream.cons/assign.move.pass.cpp | 10 ++-- .../spanstream.cons/ctor.move.pass.cpp | 10 ++-- 8 files changed, 70 insertions(+), 78 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp index 9c893e32e614b..34684f169030c 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -50,7 +50,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -67,14 +67,14 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode: multiple (`in` | `binary`) + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -84,14 +84,14 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode: `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -101,7 +101,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp index 8ed9f0aba190e..6810ce09a7634 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp @@ -38,7 +38,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -50,7 +50,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -67,48 +67,31 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode `out` + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); - // After move + // State after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt{std::move(rhsSpSt)}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - // After move - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode `ate` - { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -118,7 +101,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -136,5 +119,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 2b9c3a38dea85..f52ecfda4fa83 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -49,7 +49,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -66,7 +66,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -83,7 +83,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -100,7 +100,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -117,7 +117,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index 3c543397e4523..c6bba81e44acb 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -49,7 +49,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -66,7 +66,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -83,7 +83,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -100,7 +100,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -117,7 +117,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp index 88179fece5908..9dc7233942071 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp @@ -170,7 +170,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -188,7 +188,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -207,7 +207,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters assert(rhsSpBuf.span().empty()); @@ -227,7 +227,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -240,7 +240,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -266,7 +266,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -297,7 +297,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -316,7 +316,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -333,7 +333,7 @@ void test() { assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index d094c491ca45e..06f912425b756 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -170,7 +170,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -188,7 +188,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -207,7 +207,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters assert(rhsSpBuf.span().empty()); @@ -227,7 +227,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -240,7 +240,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == nullptr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -266,7 +266,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -283,7 +283,7 @@ void test() { assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); @@ -302,7 +302,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -321,7 +321,7 @@ void test() { assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); @@ -338,7 +338,7 @@ void test() { assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); - // After move + // Test after move assert(rhsSpBuf.span().data() == arr); assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index 2a1229445ac7e..7a0174aaa738d 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -49,7 +49,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -66,7 +66,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -83,7 +83,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -100,7 +100,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -117,7 +117,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index b70e6bf4c6b9c..37e12c5384ec7 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -49,7 +49,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -66,7 +66,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -83,7 +83,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -100,7 +100,7 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); @@ -117,7 +117,7 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); - // After move + // Test after move assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); From 6730df243d1cf98ab8686e438537210d483a0c28 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 02:33:40 +0300 Subject: [PATCH 061/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp --- libcxx/include/spanstream | 4 +- .../input.output/span.streams/helper_types.h | 5 +- .../ispanstream.cons/assign.move.pass.cpp | 1 + .../ispanstream.cons/ctor.move.pass.cpp | 1 + .../ispanstream.cons/ctor.ros.pass.cpp | 62 +++++++++++++------ 5 files changed, 52 insertions(+), 21 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index e1d6765e78a51..8acbc50064d1b 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -270,9 +270,9 @@ public: template requires(!convertible_to<_ROSeq, std::span<_CharT>>) && convertible_to<_ROSeq, std::span> _LIBCPP_HIDE_FROM_ABI explicit basic_ispanstream(_ROSeq&& __s) - : basic_istream<_CharT, _Traits>(std::addressof(__sb_)) { + : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(basic_spanbuf<_CharT, _Traits>(ios_base::in)) { std::span __sp(std::forward<_ROSeq>(__s)); - this->span(std::span<_CharT>(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size()))); + this->span(std::span<_CharT>(const_cast<_CharT*>(__sp.data()), __sp.size())); } basic_ispanstream& operator=(const basic_ispanstream&) = delete; diff --git a/libcxx/test/std/input.output/span.streams/helper_types.h b/libcxx/test/std/input.output/span.streams/helper_types.h index 79760f97e223b..0d7f99c7e653b 100644 --- a/libcxx/test/std/input.output/span.streams/helper_types.h +++ b/libcxx/test/std/input.output/span.streams/helper_types.h @@ -21,7 +21,7 @@ template class ReadOnlySpan { public: - explicit ReadOnlySpan(CharT (&arr)[N]) : arr_{arr} {} + explicit ReadOnlySpan(CharT (&arr)[N]) : arr_{arr}, size_{N} {} operator std::span() = delete; @@ -30,8 +30,11 @@ class ReadOnlySpan { const CharT* begin() { return arr_; } const CharT* end() { return arr_ + N; } + std::size_t size() const { return size_; } + private: CharT* arr_; + std::size_t size_; }; template diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp index 34684f169030c..28332bcce6337 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -112,6 +112,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp index 6810ce09a7634..4e8f5756e47a9 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp @@ -112,6 +112,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index 005e4a60f3d09..ced52bcc1420e 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -29,6 +29,13 @@ #include "../../helper_types.h" +#include + +using namespace std::string_view_literals; + +template +constexpr auto input_view = "1 2 3 4 5"sv; + template > void test_sfinae() { using SpStream = std::basic_ispanstream; @@ -56,14 +63,14 @@ void test() { // TODO: CharT arr[4]; - ReadOnlySpan ros{arr}; + assert(ros.size() == 4); { SpStream spSt(ros); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } CharT arr1[6]; @@ -73,26 +80,45 @@ void test() { SpStream spSt(ros2); assert(spSt.span().data() != arr); assert(spSt.span().data() == arr1); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 6); + } + + { + auto r = input_view; + SpStream spSt{r}; + assert(spSt.span().data() != arr); + assert(spSt.span().data() != arr1); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 9); } } int main(int, char**) { -#ifndef TEST_HAS_NO_NASTY_STRING - test_sfinae(); -#endif - test_sfinae(); - test_sfinae>(); -#ifndef TEST_HAS_NO_NASTY_STRING - test(); -#endif +// #ifndef TEST_HAS_NO_NASTY_STRING +// test_sfinae(); +// #endif +// test_sfinae(); +// test_sfinae>(); +// #ifndef TEST_HAS_NO_NASTY_STRING +// test(); +// #endif + test(); - test>(); -#ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); - test>(); -#endif +// test>(); +// #ifndef TEST_HAS_NO_WIDE_CHARACTERS +// test(); +// test>(); +// #endif + +// #ifndef TEST_HAS_NO_CHAR8_T +// test(); +// test>(); +// #endif +// test(); +// test>(); +// test(); +// test>(); return 0; } From d75e22120d598d9a7b1c9a6d14236353ce7a3834 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 02:34:37 +0300 Subject: [PATCH 062/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp --- .../ispanstream.cons/ctor.ros.pass.cpp | 75 +++++++------------ 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index ced52bcc1420e..4b24b618b73cc 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -29,13 +29,6 @@ #include "../../helper_types.h" -#include - -using namespace std::string_view_literals; - -template -constexpr auto input_view = "1 2 3 4 5"sv; - template > void test_sfinae() { using SpStream = std::basic_ispanstream; @@ -61,64 +54,54 @@ template > void test() { using SpStream = std::basic_ispanstream; - // TODO: - CharT arr[4]; - ReadOnlySpan ros{arr}; + CharT arr1[4]; + ReadOnlySpan ros{arr1}; assert(ros.size() == 4); { SpStream spSt(ros); - assert(spSt.span().data() == arr); + assert(spSt.span().data() == arr1); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - CharT arr1[6]; - ReadOnlySpan ros2{arr1}; + CharT arr2[6]; + ReadOnlySpan ros2{arr2}; { SpStream spSt(ros2); - assert(spSt.span().data() != arr); - assert(spSt.span().data() == arr1); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 6); - } - - { - auto r = input_view; - SpStream spSt{r}; - assert(spSt.span().data() != arr); assert(spSt.span().data() != arr1); + assert(spSt.span().data() == arr2); assert(!spSt.span().empty()); - assert(spSt.span().size() == 9); + assert(spSt.span().size() == 6); } } int main(int, char**) { -// #ifndef TEST_HAS_NO_NASTY_STRING -// test_sfinae(); -// #endif -// test_sfinae(); -// test_sfinae>(); -// #ifndef TEST_HAS_NO_NASTY_STRING -// test(); -// #endif +#ifndef TEST_HAS_NO_NASTY_STRING + test_sfinae(); +#endif + test_sfinae(); + test_sfinae>(); +#ifndef TEST_HAS_NO_NASTY_STRING + test(); +#endif test(); -// test>(); -// #ifndef TEST_HAS_NO_WIDE_CHARACTERS -// test(); -// test>(); -// #endif - -// #ifndef TEST_HAS_NO_CHAR8_T -// test(); -// test>(); -// #endif -// test(); -// test>(); -// test(); -// test>(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); return 0; } From b446bd6be4d09f2fbc8166d86a20a94aab11119d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 02:39:17 +0300 Subject: [PATCH 063/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp --- .../ispanstream.cons/ctor.ros.pass.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index 4b24b618b73cc..e2bbd9f806d3e 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -54,27 +54,16 @@ template > void test() { using SpStream = std::basic_ispanstream; - CharT arr1[4]; - ReadOnlySpan ros{arr1}; + CharT arr[4]; + ReadOnlySpan ros{arr}; assert(ros.size() == 4); { SpStream spSt(ros); - assert(spSt.span().data() == arr1); + assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - - CharT arr2[6]; - ReadOnlySpan ros2{arr2}; - - { - SpStream spSt(ros2); - assert(spSt.span().data() != arr1); - assert(spSt.span().data() == arr2); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 6); - } } int main(int, char**) { From 6a2d4270609eb2732fd9f7d70460e105c385c79a Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 02:41:51 +0300 Subject: [PATCH 064/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp --- .../ispanstream.cons/ctor.span.mode.pass.cpp | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index 81e544da3c263..5a02c1de6a59e 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -56,7 +56,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in`) { SpStream spSt{sp}; assert(spSt.span().data() == arr); @@ -82,41 +82,28 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode `out` + // Mode `ate` { - SpStream spSt{sp, std::ios_base::out}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::out}; + SpStream spSt{std::as_const(sp), std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode: multiple { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - { - SpStream spSt{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - // Mode `ate` - { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::as_const(sp), std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); From c2233843e9100e46d653cd603d1933f012b85127 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 02:51:09 +0300 Subject: [PATCH 065/120] Updated tests --- .../ispanstream.cons/ctor.ros.pass.cpp | 1 + .../ispanstream.cons/ctor.span.mode.pass.cpp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index e2bbd9f806d3e..af14705c41091 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -72,6 +72,7 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index 5a02c1de6a59e..3df557efa4291 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -116,17 +116,30 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); +#endif + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test_sfinae(); - test_sfinae>(); test(); test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From eb9ef8040b2d60575d8db7f508be64420485bae0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 02:57:51 +0300 Subject: [PATCH 066/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp --- .../ispanstream.members/rdbuf.pass.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp index 0b5aa94f1b88a..67924a5e66030 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp @@ -36,11 +36,10 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in`) { SpStream spSt{sp}; assert(spSt.rdbuf()->span().data() == arr); - // Mode `out` counts read characters assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } @@ -51,25 +50,16 @@ void test() { assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } - // Mode: `out` + // Mode: `ate` { - SpStream spSt{sp, std::ios_base::out}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.rdbuf()->span().data() == arr); - // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 0); + assert(!spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 4); } // Mode: multiple { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spSt.rdbuf()->span().data() == arr); - // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 0); - } - // Mode: `ate` - { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.rdbuf()->span().data() == arr); assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); @@ -80,6 +70,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -87,5 +78,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From 500b15260d0cd12d21e5fdbec29c8b02ed463595 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 03:11:35 +0300 Subject: [PATCH 067/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp --- .../ispanstream.members/span.pass.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp index e1b6734301e06..381c5b601e053 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp @@ -37,7 +37,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in` ) { SpStream spSt{sp}; assert(spSt.span().data() == arr); @@ -51,24 +51,16 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `out` + // Mode: `ate` { - SpStream spSt{sp, std::ios_base::out}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode: multiple { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - // Mode: `ate` - { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); @@ -79,6 +71,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -86,5 +79,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From e6c4c89929706573288a33bc17f7fa7469f95dec Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 03:12:08 +0300 Subject: [PATCH 068/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp --- .../ispanstream.members/span.span.pass.cpp | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp index 8603e0b87c9f7..3a139529c6a7c 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp @@ -37,7 +37,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in` ) { SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); @@ -61,35 +61,21 @@ void test() { assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `out` + // Mode: `ate` { - SpStream spSt{std::span{}, std::ios_base::out}; + SpStream spSt{std::span{}, std::ios_base::ate}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } // Mode: multiple { - SpStream spSt{std::span{}, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(arr); - assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - // Mode: `ate` - { - SpStream spSt{std::span{}, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::span{}, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -105,6 +91,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -112,5 +99,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From 7082f1fd9ee48c2c80f9d74326277acac466f0ca Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 03:17:38 +0300 Subject: [PATCH 069/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp --- .../span.streams/ispanstream/types.compile.pass.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index 9b492a9c59985..e18691d19acaf 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -63,12 +63,22 @@ void test() { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); #endif + +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); } // Aliases From b7166023fbb3a9fe1e22190a45784b1a1ece2ea5 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 03:17:51 +0300 Subject: [PATCH 070/120] Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp --- .../ispanstream.swap/swap.pass.cpp | 50 +++++++----------- .../ispanstream.swap/swap_nonmember.pass.cpp | 52 +++++++------------ 2 files changed, 38 insertions(+), 64 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp index d0abcb6b2b6d1..ba50931961049 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp @@ -36,7 +36,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -76,51 +76,29 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode `out` + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); - SpStream spSt{std::span{}}; + SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt{std::span{}}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: `ate` - { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -144,6 +122,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -151,5 +130,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp index 9b8f32d1f08b0..23f4418f778ca 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp @@ -32,7 +32,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`in`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -72,53 +72,29 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode `out` + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::out}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); - SpStream spSt{std::span{}}; + SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt{std::span{}}; - assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: `ate` - { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -142,6 +118,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -149,5 +126,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From e09c0375ef293aa5721217643339fa898e81429c Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 03:27:17 +0300 Subject: [PATCH 071/120] Updated ispanstream tests --- .../ispanstream.cons/ctor.ros.pass.cpp | 16 +++++++++++++++- .../ispanstream.cons/ctor.span.mode.pass.cpp | 10 ++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index af14705c41091..1df6ab263b9c0 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -70,9 +70,23 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test_sfinae(); #endif + test_sfinae(); test_sfinae>(); - +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); +#endif + +#ifndef TEST_HAS_NO_CHAR8_T + test_sfinae(); + test_sfinae>(); +#endif + test_sfinae(); + test_sfinae>(); + test_sfinae(); + test_sfinae>(); + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index 3df557efa4291..98c8c83378adc 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -114,6 +114,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test_sfinae(); #endif + test_sfinae(); test_sfinae>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -121,6 +122,15 @@ int main(int, char**) { test_sfinae>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test_sfinae(); + test_sfinae>(); +#endif + test_sfinae(); + test_sfinae>(); + test_sfinae(); + test_sfinae>(); + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif From 63f02f90cc94af1e10d3c402a8ecf3b82bda9095 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 10:06:27 +0300 Subject: [PATCH 072/120] Added libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp --- .../span.streams/helper_functions.h | 21 ++ .../ispanstream/inherited.stream.ops.pass.cpp | 343 ++++++++++++++++++ 2 files changed, 364 insertions(+) create mode 100644 libcxx/test/std/input.output/span.streams/helper_functions.h create mode 100644 libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/helper_functions.h b/libcxx/test/std/input.output/span.streams/helper_functions.h new file mode 100644 index 0000000000000..5a3a8a10c7fd5 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/helper_functions.h @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_STD_INPUTOUTPUT_SPANSTREAMS_FUNCTIONS_H +#define TEST_STD_INPUTOUTPUT_SPANSTREAMS_FUNCTIONS_H + +#include + +template > +void initialize_array_from_string_view(CharT* arr, std::basic_string_view sv) { + for (std::size_t i = 0; i != sv.size(); ++i) { + arr[i] = sv[i]; + } +} + +#endif // TEST_STD_INPUTOUTPUT_SPANSTREAMS_FUNCTIONS_H diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp new file mode 100644 index 0000000000000..d93a84ed6d91b --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -0,0 +1,343 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// Test stream operations inherited from `basic_istream` and `basic_ostream` + +#include + +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +#include "../helper_functions.h" +#include "../helper_macros.h" + +template > +void test() { + using SpStream = std::basic_ispanstream; + + constexpr auto arrSize{30UZ}; + + constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; + assert(sv.size() < arrSize); + + CharT arr[arrSize]{}; + initialize_array_from_string_view(arr, sv); + + std::span sp{arr}; + + // Mode: default (`in`) + { + SpStream spSt(sp); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + // std::println(stderr, CS("-------> {}"), spSt.span().size()); + // std::println("Hello world!~"); + assert(spSt.span().size() == arrSize); + + // std::print(stderr, "span ---->"); + // for (std::size_t i = 0; i != spSt.span().size(); ++i) + // std::print(stderr, "{}, ", spSt.span().at(i)); + // std::println(); + + // Read from stream + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + int i3; + spSt >> i3; + + assert(str1 == CS("zmt")); + assert(i1 == 94); + // assert(false); + } + +#if 0 + // Mode: default (`in` | `out`) + { + SpStream spSt(sp); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + assert(spSt.span().size() == 0); + + // Read from stream + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + int i3; + spSt >> i3; + + assert(str1 == CS("zmt")); + assert(i1 == 94); + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + assert(i3 == 43); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + + // Write to stream + constexpr std::basic_string_view sv1{SV("year 2024")}; + spSt << sv1; + + assert(spSt.span().size() == sv1.size()); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + + // Read from stream + spSt.seekg(0); + std::basic_string str4; + spSt >> str4; + int i4; + spSt >> i4; + + assert(str4 == CS("year")); + assert(i4 == 2024); + + spSt >> i4; + + assert(!spSt); + assert(!spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); + + spSt.clear(); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + + // Write to stream + spSt << CS("94"); + spSt << 84; + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + + assert(spSt.span().size() == sv1.size() + 4); + std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr1 == CS("year 20249484")); + + // Write to stream with overflow + constexpr std::basic_string_view sv2{ + SV("This string should overflow! This string should overflow!")}; + spSt << sv2; + assert(spSt.span().size() == arrSize); + std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr2 == CS("year 20249484This string shoul")); + + assert(!spSt); + assert(spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); + } + + // Mode: `in` + { + SpStream spSt{sp, std::ios_base::in}; + assert(spSt); + assert(spSt.good()); + assert(spSt.span().size() == arrSize); + + std::basic_string expectedStr0{spSt.span().data(), std::size_t{spSt.span().size()}}; + std::cout << expectedStr0 << std::endl; + + // // Read from stream + // std::basic_string str1; + // spSt >> str1; + // int i1; + // spSt >> i1; + // std::basic_string str2; + // spSt >> str2; + // int i2; + // spSt >> i2; + // std::basic_string str3; + // spSt >> str3; + // int i3; + // spSt >> i3; + + // assert(spSt.good()); + // assert(str1 == CS("zmt")); + // assert(i1 == 94); + // assert(str2 == CS("hkt")); + // assert(i2 == 82); + // assert(str3 == CS("pir")); + // assert(i3 == 43); + + // Write to stream + constexpr std::basic_string_view sv1{SV("year 2024")}; + spSt << sv1; + + std::cout << spSt.span().size() << std::endl; + assert(spSt.span().size() == sv1.size()); + assert(spSt.good()); + + // Read from stream + spSt.seekg(0); + std::basic_string str4; + spSt >> str4; + int i4; + spSt >> i4; + + assert(str4 == CS("year")); + assert(i4 == 2024); + + spSt >> i4; + assert(spSt); + assert(!spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); + + spSt.clear(); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + // Write to stream + spSt << CS("94"); + spSt << 84; + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); assert(spSt.span().size() == sv1.size() + 4); + std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr1 == CS("year 20249484")); + + // Write to stream with overflow + constexpr std::basic_string_view sv2{ + SV("This string should overflow! This string should overflow!")}; + spSt << sv2; + assert(spSt.span().size() == arrSize); + std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr2 == CS("year 20249484This string shoul")); + assert(spSt); + assert(!spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); } + // Mode `out` + { + SpStream spSt{sp, std::ios_base::out}; + assert(spSt.span().size() == 0); + + // Read from stream + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + int i3; + spSt >> i3; + + assert(spSt.good()); + assert(str1 == CS("zmt")); + assert(i1 == 94); + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + assert(i3 == 43); + + // Write to stream + constexpr std::basic_string_view sv1{SV("year 2024")}; + spSt << sv1; + + assert(spSt.span().size() == sv1.size()); + assert(spSt.good()); + + // Read from stream + spSt.seekg(0); + std::basic_string str4; + spSt >> str4; + int i4; + spSt >> i4; + + assert(str4 == CS("year")); + assert(i4 == 2024); + + spSt >> i4; + assert(spSt.fail()); + spSt.clear(); + assert(spSt.good()); + + // Write to stream + spSt << CS("94"); + spSt << 84; + + assert(spSt.good()); + assert(spSt.span().size() == sv1.size() + 4); + std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr1 == CS("year 20249484")); + + // Write to stream with overflow + constexpr std::basic_string_view sv2{ + SV("This string should overflow! This string should overflow!")}; + spSt << sv2; + assert(spSt.span().size() == arrSize); + std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; + assert(expectedStr2 == CS("year 20249484This string shoul")); + assert(spSt.fail()); + } +#endif +} + +int main(int, char**) { + test(); + test>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); + test>(); +#endif + + return 0; +} From af9d416e92ac836042847590b41cbcf38a3e91d7 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 12:08:56 +0300 Subject: [PATCH 073/120] Updated: libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp --- .../ispanstream/inherited.stream.ops.pass.cpp | 240 +++++------------- 1 file changed, 68 insertions(+), 172 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp index d93a84ed6d91b..dc57dbb1c1046 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -29,22 +29,30 @@ #include "../helper_functions.h" #include "../helper_macros.h" +#include "../helper_types.h" template > void test() { using SpStream = std::basic_ispanstream; - constexpr auto arrSize{30UZ}; - constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; + constexpr auto arrSize{30UZ}; assert(sv.size() < arrSize); + // Create a std::span test value CharT arr[arrSize]{}; initialize_array_from_string_view(arr, sv); std::span sp{arr}; - // Mode: default (`in`) + // Create a "Read Only Sequence" test value + CharT rosArr[arrSize]{}; + initialize_array_from_string_view(rosArr, sv); + + ReadOnlySpan ros{rosArr}; + assert(ros.size() == arrSize); + + // `std::span` + Mode: default (`in`) { SpStream spSt(sp); @@ -52,15 +60,8 @@ void test() { assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); - // std::println(stderr, CS("-------> {}"), spSt.span().size()); - // std::println("Hello world!~"); assert(spSt.span().size() == arrSize); - // std::print(stderr, "span ---->"); - // for (std::size_t i = 0; i != spSt.span().size(); ++i) - // std::print(stderr, "{}, ", spSt.span().at(i)); - // std::println(); - // Read from stream std::basic_string str1; spSt >> str1; @@ -77,11 +78,24 @@ void test() { assert(str1 == CS("zmt")); assert(i1 == 94); - // assert(false); - } + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + assert(i3 == 43); -#if 0 - // Mode: default (`in` | `out`) + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + + spSt.clear(); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + } + // `ReadOnlySpan` + Mode: default (`in`) { SpStream spSt(sp); @@ -89,7 +103,7 @@ void test() { assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); - assert(spSt.span().size() == 0); + assert(spSt.span().size() == arrSize); // Read from stream std::basic_string str1; @@ -117,154 +131,66 @@ void test() { assert(!spSt.fail()); assert(spSt.good()); - // Write to stream - constexpr std::basic_string_view sv1{SV("year 2024")}; - spSt << sv1; - - assert(spSt.span().size() == sv1.size()); - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - - // Read from stream - spSt.seekg(0); - std::basic_string str4; - spSt >> str4; - int i4; - spSt >> i4; - - assert(str4 == CS("year")); - assert(i4 == 2024); - - spSt >> i4; - - assert(!spSt); - assert(!spSt.bad()); - assert(spSt.fail()); - assert(!spSt.good()); - spSt.clear(); assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); + } - // Write to stream - spSt << CS("94"); - spSt << 84; + // `std::span` + Mode: `ate` + { + SpStream spSt(sp, std::ios_base::ate); assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); - - assert(spSt.span().size() == sv1.size() + 4); - std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; - assert(expectedStr1 == CS("year 20249484")); - - // Write to stream with overflow - constexpr std::basic_string_view sv2{ - SV("This string should overflow! This string should overflow!")}; - spSt << sv2; - assert(spSt.span().size() == arrSize); - std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; - assert(expectedStr2 == CS("year 20249484This string shoul")); - - assert(!spSt); - assert(spSt.bad()); - assert(spSt.fail()); - assert(!spSt.good()); - } - - // Mode: `in` - { - SpStream spSt{sp, std::ios_base::in}; - assert(spSt); - assert(spSt.good()); assert(spSt.span().size() == arrSize); - std::basic_string expectedStr0{spSt.span().data(), std::size_t{spSt.span().size()}}; - std::cout << expectedStr0 << std::endl; - - // // Read from stream - // std::basic_string str1; - // spSt >> str1; - // int i1; - // spSt >> i1; - // std::basic_string str2; - // spSt >> str2; - // int i2; - // spSt >> i2; - // std::basic_string str3; - // spSt >> str3; - // int i3; - // spSt >> i3; - - // assert(spSt.good()); - // assert(str1 == CS("zmt")); - // assert(i1 == 94); - // assert(str2 == CS("hkt")); - // assert(i2 == 82); - // assert(str3 == CS("pir")); - // assert(i3 == 43); - - // Write to stream - constexpr std::basic_string_view sv1{SV("year 2024")}; - spSt << sv1; - - std::cout << spSt.span().size() << std::endl; - assert(spSt.span().size() == sv1.size()); - assert(spSt.good()); - // Read from stream - spSt.seekg(0); - std::basic_string str4; - spSt >> str4; - int i4; - spSt >> i4; + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + int i3; + spSt >> i3; - assert(str4 == CS("year")); - assert(i4 == 2024); + assert(str1 == CS("zmt")); + assert(i1 == 94); + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + assert(i3 == 43); - spSt >> i4; assert(spSt); assert(!spSt.bad()); - assert(spSt.fail()); - assert(!spSt.good()); + assert(!spSt.fail()); + assert(spSt.good()); + + spSt.clear(); - spSt.clear(); assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); - // Write to stream - spSt << CS("94"); - spSt << 84; + } + // `ReadOnlySpan` + Mode: `ate` + { + SpStream spSt(sp, std::ios_base::ate); assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); - assert(spSt.good()); assert(spSt.span().size() == sv1.size() + 4); - std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; - assert(expectedStr1 == CS("year 20249484")); - - // Write to stream with overflow - constexpr std::basic_string_view sv2{ - SV("This string should overflow! This string should overflow!")}; - spSt << sv2; + assert(spSt.good()); assert(spSt.span().size() == arrSize); - std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; - assert(expectedStr2 == CS("year 20249484This string shoul")); - assert(spSt); - assert(!spSt.bad()); - assert(spSt.fail()); - assert(!spSt.good()); } - // Mode `out` - { - SpStream spSt{sp, std::ios_base::out}; - assert(spSt.span().size() == 0); // Read from stream std::basic_string str1; @@ -280,7 +206,6 @@ void test() { int i3; spSt >> i3; - assert(spSt.good()); assert(str1 == CS("zmt")); assert(i1 == 94); assert(str2 == CS("hkt")); @@ -288,55 +213,26 @@ void test() { assert(str3 == CS("pir")); assert(i3 == 43); - // Write to stream - constexpr std::basic_string_view sv1{SV("year 2024")}; - spSt << sv1; - - assert(spSt.span().size() == sv1.size()); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); assert(spSt.good()); - // Read from stream - spSt.seekg(0); - std::basic_string str4; - spSt >> str4; - int i4; - spSt >> i4; - - assert(str4 == CS("year")); - assert(i4 == 2024); - - spSt >> i4; - assert(spSt.fail()); spSt.clear(); - assert(spSt.good()); - - // Write to stream - spSt << CS("94"); - spSt << 84; + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); assert(spSt.good()); - assert(spSt.span().size() == sv1.size() + 4); - std::basic_string expectedStr1{spSt.span().data(), std::size_t{spSt.span().size()}}; - assert(expectedStr1 == CS("year 20249484")); - - // Write to stream with overflow - constexpr std::basic_string_view sv2{ - SV("This string should overflow! This string should overflow!")}; - spSt << sv2; - assert(spSt.span().size() == arrSize); - std::basic_string expectedStr2{spSt.span().data(), std::size_t{spSt.span().size()}}; - assert(expectedStr2 == CS("year 20249484This string shoul")); - assert(spSt.fail()); } -#endif } int main(int, char**) { test(); - test>(); + // test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); - test>(); + // test>(); #endif return 0; From 2838485c39eaf90bc8b84790d09e3f9ee43bcaaf Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 13:15:10 +0300 Subject: [PATCH 074/120] ispanstream + constexpr_char_traits: returns empty strings --- .../ispanstream/inherited.stream.ops.pass.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp index dc57dbb1c1046..8c7c4dfec52a1 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -76,11 +76,27 @@ void test() { int i3; spSt >> i3; + // TODO: Subsequent reads with constexpr_char_traits return empty string: + // # .---command stderr------------ + // # | -----> zmt + // # | -----> 94 + // # | -----> hkt + // # | -----> 82 + // # | -----> pir + // # | -----> zmt + // # | -----> 94 + // # | -----> + // # | -----> 82 assert(str1 == CS("zmt")); + std::println(stderr, "-----> {}", str1); assert(i1 == 94); - assert(str2 == CS("hkt")); + std::println(stderr, "-----> {}", i1); + std::println(stderr, "-----> {}", str2); + // assert(str2 == CS("hkt")); assert(i2 == 82); + std::println(stderr, "-----> {}", i2); assert(str3 == CS("pir")); + std::println(stderr, "-----> {}", str3); assert(i3 == 43); assert(spSt); @@ -229,9 +245,9 @@ void test() { int main(int, char**) { test(); - // test>(); + test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); + // test(); // test>(); #endif From 1997256485a951484cd1d2a32d07bc6ca2f898f0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 13:16:52 +0300 Subject: [PATCH 075/120] Removed constexpr_char_traits from tests --- .../ispanstream/inherited.stream.ops.pass.cpp | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp index 8c7c4dfec52a1..2d73c9a6e244f 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -16,8 +16,6 @@ // Test stream operations inherited from `basic_istream` and `basic_ostream` -#include - #include #include #include @@ -76,27 +74,11 @@ void test() { int i3; spSt >> i3; - // TODO: Subsequent reads with constexpr_char_traits return empty string: - // # .---command stderr------------ - // # | -----> zmt - // # | -----> 94 - // # | -----> hkt - // # | -----> 82 - // # | -----> pir - // # | -----> zmt - // # | -----> 94 - // # | -----> - // # | -----> 82 assert(str1 == CS("zmt")); - std::println(stderr, "-----> {}", str1); assert(i1 == 94); - std::println(stderr, "-----> {}", i1); - std::println(stderr, "-----> {}", str2); - // assert(str2 == CS("hkt")); + assert(str2 == CS("hkt")); assert(i2 == 82); - std::println(stderr, "-----> {}", i2); assert(str3 == CS("pir")); - std::println(stderr, "-----> {}", str3); assert(i3 == 43); assert(spSt); @@ -245,10 +227,8 @@ void test() { int main(int, char**) { test(); - test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - // test(); - // test>(); + test(); #endif return 0; From b9d40dee9f381251938533b5763eaa1cfe3ce584 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 14:19:33 +0300 Subject: [PATCH 076/120] Updated: libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp --- .../ospanstream.cons/assign.move.pass.cpp | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index f52ecfda4fa83..4d06a724afd1e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -37,7 +37,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -54,23 +54,6 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: `in` - { - SpStream rhsSpSt{sp, std::ios_base::in}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt = std::move(rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; @@ -88,26 +71,26 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } - // Mode `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -128,6 +111,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -135,5 +119,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From 2167a5b72b58fa259123e7539a1a81b113073486 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 14:24:20 +0300 Subject: [PATCH 077/120] Updated: libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp --- .../ospanstream.cons/ctor.move.pass.cpp | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index c6bba81e44acb..ef0121299c30e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -37,7 +37,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -54,23 +54,6 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: `in` - { - SpStream rhsSpSt{sp, std::ios_base::in}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt{std::move(rhsSpSt)}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; @@ -88,26 +71,26 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } - // Mode `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -128,6 +111,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -135,5 +119,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From 4f0b6e6bb2601c04f903b051bcf0e6843fe32f3c Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 14:42:53 +0300 Subject: [PATCH 078/120] Updated: `basic_ostream` tests --- .../ospanstream/inherited.stream.ops.pass.cpp | 72 +++++++++++++++++++ .../ospanstream.cons/assign.move.pass.cpp | 2 + .../ospanstream.cons/ctor.move.pass.cpp | 6 +- .../ospanstream.cons/ctor.span.mode.pass.cpp | 66 ++++++++++------- .../ospanstream.members/rdbuf.pass.cpp | 33 +++++---- .../ospanstream.members/span.pass.cpp | 32 +++++---- .../ospanstream.members/span.span.pass.cpp | 37 +++++----- .../ospanstream.swap/swap.pass.cpp | 52 ++++++-------- .../ospanstream.swap/swap_nonmember.pass.cpp | 52 ++++++-------- .../ospanstream/types.compile.pass.cpp | 10 +++ 10 files changed, 221 insertions(+), 141 deletions(-) create mode 100644 libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp new file mode 100644 index 0000000000000..fec68424cf7b3 --- /dev/null +++ b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// + +// template> +// class basic_spanstream +// : public basic_iostream { + +// Test stream operations inherited from `basic_istream` and `basic_ostream` + +#include +#include +#include +#include +#include + +#include "constexpr_char_traits.h" +#include "test_macros.h" + +#include "../helper_functions.h" +#include "../helper_macros.h" +#include "../helper_types.h" + +template > +void test() { + using SpStream = std::basic_ospanstream; + + constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; + constexpr auto arrSize{30UZ}; + assert(sv.size() < arrSize); + + // Create a std::span test value + CharT arr[arrSize]{}; + initialize_array_from_string_view(arr, sv); + + std::span sp{arr}; + + // `std::span` + Mode: default (`out`) + { + SpStream spSt(sp); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + assert(spSt.span().size() == 0); + + spSt.clear(); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + } +} + +int main(int, char**) { + test(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test(); +#endif + + return 0; +} diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 4d06a724afd1e..357eea47cb13e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -41,11 +41,13 @@ void test() { { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index ef0121299c30e..6a1c38ff7b383 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -41,11 +41,13 @@ void test() { { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -58,11 +60,13 @@ void test() { { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -73,7 +77,7 @@ void test() { } // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp index bc70fb4a440a7..d4cbd5883d5c0 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp @@ -55,29 +55,18 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream spSt{sp}; assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - // Mode: `in` - { - SpStream spSt{sp, std::ios_base::in}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } - { - SpStream spSt{std::as_const(sp), std::ios_base::in}; - assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); } @@ -85,37 +74,39 @@ void test() { { SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { SpStream spSt{std::as_const(sp), std::ios_base::out}; assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: multiple + // Mode `ate` { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::as_const(sp), std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } - // Mode `ate` + // Mode: multiple { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::as_const(sp), std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); @@ -126,19 +117,42 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test_sfinae(); #endif + test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); +#endif + +#ifndef TEST_HAS_NO_CHAR8_T + test_sfinae(); + test_sfinae>(); +#endif + test_sfinae(); + test_sfinae>(); + test_sfinae(); + test_sfinae>(); + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test_sfinae(); - test_sfinae>(); test(); test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp index fac9df7c7d913..135fe0a026a58 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp @@ -36,7 +36,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream spSt{sp}; assert(spSt.rdbuf()->span().data() == arr); @@ -44,13 +44,6 @@ void test() { assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } - // Mode: `in` - { - SpStream spSt{sp, std::ios_base::in}; - assert(spSt.rdbuf()->span().data() == arr); - assert(spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 0); - } // Mode: `out` { SpStream spSt{sp, std::ios_base::out}; @@ -59,27 +52,28 @@ void test() { assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.rdbuf()->span().data() == arr); - // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 0); + assert(!spSt.rdbuf()->span().empty()); + assert(spSt.rdbuf()->span().size() == 4); } - // Mode: `ate` + // Mode: multiple { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.rdbuf()->span().data() == arr); assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); } + } int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -87,5 +81,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp index f92ed56c53b6d..82d4fa9be1125 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp @@ -37,7 +37,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream spSt{sp}; assert(spSt.span().data() == arr); @@ -45,13 +45,6 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: `in` - { - SpStream spSt{sp, std::ios_base::in}; - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } // Mode: `out` { SpStream spSt{sp, std::ios_base::out}; @@ -60,17 +53,16 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } - // Mode: `ate` + // Mode: multiple { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); @@ -81,6 +73,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -88,5 +81,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp index fab565d97a286..1ae821b26bc2b 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp @@ -37,7 +37,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); @@ -50,18 +50,6 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: `in` - { - SpStream spSt{std::span{}, std::ios_base::in}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(arr); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - } // Mode: `out` { SpStream spSt{std::span{}, std::ios_base::out}; @@ -75,22 +63,21 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream spSt{std::span{}, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::span{}, std::ios_base::ate}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } - // Mode: `ate` + // Mode: multiple { - SpStream spSt{std::span{}, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::span{}, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == nullptr); assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -106,6 +93,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -113,5 +101,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp index 9521118f27e3e..bed53cf086577 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp @@ -36,7 +36,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -58,26 +58,6 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: `in` - { - SpStream rhsSpSt{sp, std::ios_base::in}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; @@ -100,31 +80,29 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); - SpStream spSt{std::span{}}; + SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -148,6 +126,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -155,5 +134,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp index fc3f9a57afcf5..cf9c146945cc8 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp @@ -32,7 +32,7 @@ void test() { assert(!sp.empty()); assert(sp.size() == 4); - // Mode: default (`in` | `out`) + // Mode: default (`out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); @@ -54,26 +54,6 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: `in` - { - SpStream rhsSpSt{sp, std::ios_base::in}; - assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; @@ -96,31 +76,29 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); - SpStream spSt{std::span{}}; + SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -144,6 +122,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -151,5 +130,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index 71f76790d66fd..92eaf4ada2f80 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -63,12 +63,22 @@ void test() { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test>(); #endif + +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); } // Aliases From 01ecbbeeee6ab5b9856f9dc2ceec944d74ae2600 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 5 Aug 2024 14:58:51 +0300 Subject: [PATCH 079/120] Fixed formatting --- .../span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp index 135fe0a026a58..2f9dc0a5a4025 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp @@ -66,7 +66,6 @@ void test() { assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); } - } int main(int, char**) { From f75927be9e3d19a40fde4d704690bdf373b146ca Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 16 Aug 2024 16:50:07 +0300 Subject: [PATCH 080/120] WIP: ospanstream tests --- .../ospanstream.cons/assign.move.pass.cpp | 4 +- .../spanstream.cons/assign.move.pass.cpp | 30 ++++++++---- .../spanstream.cons/ctor.move.pass.cpp | 30 ++++++++---- .../spanstream.cons/ctor.span.mode.pass.cpp | 47 ++++++++++++++----- 4 files changed, 78 insertions(+), 33 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 357eea47cb13e..5421cf05f690c 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -60,11 +60,13 @@ void test() { { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); + // Mode `out` counts read characters assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); + // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); @@ -75,7 +77,7 @@ void test() { } // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index 7a0174aaa738d..aacc0a6fbed43 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -88,26 +88,26 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } - // Mode `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -128,6 +128,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -135,5 +136,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index 37e12c5384ec7..ec68018fc5a82 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -88,26 +88,26 @@ void test() { assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(!rhsSpSt.span().empty()); + assert(rhsSpSt.span().size() == 4); } - // Mode `ate` + // Mode: multiple { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(rhsSpSt.span().data() == arr); assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); @@ -128,6 +128,7 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -135,5 +136,14 @@ int main(int, char**) { test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 3276a2a25dadc..958af252af3fe 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -93,28 +93,28 @@ void test() { assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: multiple + // Mode `ate` { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::as_const(sp), std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); } - // Mode `ate` + // Mode: multiple { - SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; + SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; + SpStream spSt{std::as_const(sp), std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == arr); assert(!spSt.span().empty()); assert(spSt.span().size() == 4); @@ -125,19 +125,42 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test_sfinae(); #endif + test_sfinae(); test_sfinae>(); +#ifndef TEST_HAS_NO_WIDE_CHARACTERS + test_sfinae(); + test_sfinae>(); +#endif + +#ifndef TEST_HAS_NO_CHAR8_T + test_sfinae(); + test_sfinae>(); +#endif + test_sfinae(); + test_sfinae>(); + test_sfinae(); + test_sfinae>(); + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif + test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test_sfinae(); - test_sfinae>(); test(); test>(); #endif +#ifndef TEST_HAS_NO_CHAR8_T + test(); + test>(); +#endif + test(); + test>(); + test(); + test>(); + return 0; } From 004baf9334368274d3bd45de9a32690333163af9 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 8 Oct 2024 09:45:39 +0300 Subject: [PATCH 081/120] Try to fix merge conflict fixes --- libcxx/include/module.modulemap.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in index ac497208bdce4..880593b1e185d 100644 --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -1997,6 +1997,13 @@ module std [system] { export std.iterator.reverse_iterator } + module spanstream { + module fwd { header "__fwd/spanstream.h" } + + header "spanstream" + export * + } + module sstream { module fwd { header "__fwd/sstream.h" } From fa8ed8cfccbdb2c76ad8e26e7da874360ac29440 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 8 Oct 2024 09:46:49 +0300 Subject: [PATCH 082/120] Fix the fixes that fix the fixes --- libcxx/docs/Status/Cxx23Papers.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv index f7d087c499da8..b260d6a72fff9 100644 --- a/libcxx/docs/Status/Cxx23Papers.csv +++ b/libcxx/docs/Status/Cxx23Papers.csv @@ -12,7 +12,7 @@ "`P2259R1 `__","Repairing input range adaptors and counted_iterator","2021-02 (Virtual)","","","" "","","","","","" "`P0401R6 `__","Providing size feedback in the Allocator interface","2021-06 (Virtual)","|Complete|","15","" -"`P0448R4 `__","A ``strstream`` replacement using ``span`` as buffer","June 2021","|Complete|","21" +"`P0448R4 `__","A ``strstream`` replacement using ``span`` as buffer","2021-06 (Virtual)","|Complete|","21" "`P1132R8 `__","out_ptr - a scalable output pointer abstraction","2021-06 (Virtual)","|Complete|","19","" "`P1328R1 `__","Making std::type_info::operator== constexpr","2021-06 (Virtual)","|Complete|","17","" "`P1425R4 `__","Iterators pair constructors for stack and queue","2021-06 (Virtual)","|Complete|","14","" From 33f060c05ec6b55e65d6e7d604c61c6a1e7bea59 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 8 Oct 2024 20:47:35 +0300 Subject: [PATCH 083/120] Fixed transitive includes --- .../test/libcxx/transitive_includes/cxx03.csv | 48 ++++++++++++++++++ .../test/libcxx/transitive_includes/cxx11.csv | 48 ++++++++++++++++++ .../test/libcxx/transitive_includes/cxx14.csv | 48 ++++++++++++++++++ .../test/libcxx/transitive_includes/cxx17.csv | 48 ++++++++++++++++++ .../test/libcxx/transitive_includes/cxx20.csv | 48 ++++++++++++++++++ .../test/libcxx/transitive_includes/cxx23.csv | 49 +++++++++++++++++++ .../test/libcxx/transitive_includes/cxx26.csv | 49 +++++++++++++++++++ 7 files changed, 338 insertions(+) diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index c556b25fa70f9..52907ade550a1 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -1922,13 +1922,61 @@ span utility span variant span vector span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream algorithm sstream array diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index c556b25fa70f9..52907ade550a1 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -1922,13 +1922,61 @@ span utility span variant span vector span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream algorithm sstream array diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 6a84538751fa0..c6d364f314f6d 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -1960,13 +1960,61 @@ span utility span variant span vector span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream algorithm sstream array diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index 1f9ee0fff7897..16c0235061eff 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -1975,13 +1975,61 @@ span utility span variant span vector span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream algorithm sstream array diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index f9def06373084..af671adbfd223 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -1993,13 +1993,61 @@ span utility span variant span vector span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream algorithm sstream array diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index 8bc14a6b9c86e..ce0c6e3c2607a 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -886,12 +886,61 @@ span initializer_list span limits span stdexcept span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple +spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream bitset sstream cctype diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index bed716fd88efa..c3acc1b35afc2 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -872,12 +872,61 @@ span initializer_list span limits span stdexcept span version +spanstream algorithm +spanstream array +spanstream atomic +spanstream bit +spanstream bitset +spanstream cctype +spanstream cerrno +spanstream climits +spanstream clocale +spanstream cmath +spanstream compare +spanstream concepts +spanstream cstdarg spanstream cstddef +spanstream cstdint +spanstream cstdio +spanstream cstdlib +spanstream cstring +spanstream ctime +spanstream cwchar +spanstream cwctype +spanstream deque +spanstream exception +spanstream format +spanstream functional spanstream initializer_list +spanstream ios +spanstream iosfwd spanstream iostream +spanstream istream +spanstream iterator spanstream limits +spanstream locale +spanstream memory +spanstream mutex +spanstream new +spanstream optional +spanstream ostream +spanstream print +spanstream queue +spanstream ratio spanstream span +spanstream stack +spanstream stdexcept spanstream streambuf +spanstream string +spanstream string_view +spanstream system_error +spanstream tuple +spanstream type_traits +spanstream typeinfo +spanstream unordered_map +spanstream utility +spanstream variant +spanstream vector spanstream version sstream bitset sstream cctype From 425e0f4a21f00bc3e1cfb8f31c3c20d34b036662 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 8 Oct 2024 21:12:46 +0300 Subject: [PATCH 084/120] Fixed transitive includes --- .../test/libcxx/transitive_includes/cxx14.csv | 1 + .../test/libcxx/transitive_includes/cxx23.csv | 19 ------------------- .../test/libcxx/transitive_includes/cxx26.csv | 19 ------------------- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index c6d364f314f6d..24aba8774f082 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -1983,6 +1983,7 @@ spanstream cwchar spanstream cwctype spanstream deque spanstream exception +spanstream execution spanstream format spanstream functional spanstream initializer_list diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index ce0c6e3c2607a..4be448b09d629 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -886,10 +886,7 @@ span initializer_list span limits span stdexcept span version -spanstream algorithm spanstream array -spanstream atomic -spanstream bit spanstream bitset spanstream cctype spanstream cerrno @@ -897,8 +894,6 @@ spanstream climits spanstream clocale spanstream cmath spanstream compare -spanstream concepts -spanstream cstdarg spanstream cstddef spanstream cstdint spanstream cstdio @@ -907,40 +902,26 @@ spanstream cstring spanstream ctime spanstream cwchar spanstream cwctype -spanstream deque -spanstream exception spanstream format -spanstream functional spanstream initializer_list spanstream ios spanstream iosfwd spanstream iostream spanstream istream -spanstream iterator spanstream limits spanstream locale -spanstream memory -spanstream mutex spanstream new spanstream optional spanstream ostream spanstream print -spanstream queue spanstream ratio spanstream span -spanstream stack spanstream stdexcept spanstream streambuf spanstream string spanstream string_view -spanstream system_error spanstream tuple -spanstream type_traits spanstream typeinfo -spanstream unordered_map -spanstream utility -spanstream variant -spanstream vector spanstream version sstream bitset sstream cctype diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index c3acc1b35afc2..6ff0a31985539 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -872,10 +872,7 @@ span initializer_list span limits span stdexcept span version -spanstream algorithm spanstream array -spanstream atomic -spanstream bit spanstream bitset spanstream cctype spanstream cerrno @@ -883,8 +880,6 @@ spanstream climits spanstream clocale spanstream cmath spanstream compare -spanstream concepts -spanstream cstdarg spanstream cstddef spanstream cstdint spanstream cstdio @@ -893,40 +888,26 @@ spanstream cstring spanstream ctime spanstream cwchar spanstream cwctype -spanstream deque -spanstream exception spanstream format -spanstream functional spanstream initializer_list spanstream ios spanstream iosfwd spanstream iostream spanstream istream -spanstream iterator spanstream limits spanstream locale -spanstream memory -spanstream mutex spanstream new spanstream optional spanstream ostream spanstream print -spanstream queue spanstream ratio spanstream span -spanstream stack spanstream stdexcept spanstream streambuf spanstream string spanstream string_view -spanstream system_error spanstream tuple -spanstream type_traits spanstream typeinfo -spanstream unordered_map -spanstream utility -spanstream variant -spanstream vector spanstream version sstream bitset sstream cctype From b7490de57cb186644f0e61bef8ca63f352c36522 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 10 Oct 2024 18:30:56 +0300 Subject: [PATCH 085/120] Try to fix build --- libcxx/include/spanstream | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 8acbc50064d1b..d4d104e096e71 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -63,6 +63,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/swap.h> +#include #include #include #include From 81d1ed1059ff7880ff75969b18926164d393bb51 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 12 Oct 2024 07:56:24 +0300 Subject: [PATCH 086/120] `spanstream` does not support `no-localization` --- libcxx/include/spanstream | 61 +++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index d4d104e096e71..d4067106b4973 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -54,31 +54,34 @@ // clang-format on -#include <__concepts/convertible_to.h> #include <__config> -#include <__fwd/spanstream.h> -#include <__memory/addressof.h> -#include <__ranges/concepts.h> -#include <__utility/cmp.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include <__utility/swap.h> -#include -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif + +#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +# include <__concepts/convertible_to.h> +# include <__fwd/spanstream.h> +# include <__memory/addressof.h> +# include <__ranges/concepts.h> +# include <__utility/cmp.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -#include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 // Class template basic_spanbuf [spanbuf] @@ -240,9 +243,9 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_spanbuf<_CharT, _Traits>& __x, basic_spanb } using std::spanbuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wspanbuf; -# endif +# endif // Class template basic_ispanstream [ispanstream] @@ -318,9 +321,9 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_ispanstream<_CharT, _Traits>& __x, basic_i } using std::ispanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wispanstream; -# endif +# endif // Class template basic_ospanstream [ospanstream] @@ -381,9 +384,9 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_ospanstream<_CharT, _Traits>& __x, basic_o } using std::ospanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wospanstream; -# endif +# endif template class _LIBCPP_TEMPLATE_VIS basic_spanstream : public basic_iostream<_CharT, _Traits> { @@ -442,16 +445,18 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_spanstream<_CharT, _Traits>& __x, basic_sp } using std::spanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wspanstream; -# endif +# endif -#endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS +#endif // !_LIBCPP_HAS_NO_LOCALIZATION + #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) # include #endif From 2839a087c81069b145ea7abd1173b0e76554278d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 13 Feb 2025 14:49:34 +0200 Subject: [PATCH 087/120] Target LLVM21 --- libcxx/docs/ReleaseNotes/20.rst | 1 - libcxx/docs/ReleaseNotes/21.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst index 7561e51a3a36a..572d4321dc46f 100644 --- a/libcxx/docs/ReleaseNotes/20.rst +++ b/libcxx/docs/ReleaseNotes/20.rst @@ -45,7 +45,6 @@ Implemented Papers - P2609R3: Relaxing Ranges Just A Smidge (`Github `__) - P2985R0: A type trait for detecting virtual base classes (`Github `__) - ``std::jthread`` and ```` are not guarded behind ``-fexperimental-library`` anymore -- P0448R4 - A ``strstream`` replacement using ``span`` as buffer - P2674R1: A trait for implicit lifetime types (`Github `__) - P0429R9: A Standard ``flat_map`` (`Github `__) diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst index d31ca0130cb80..cd9883e1c8785 100644 --- a/libcxx/docs/ReleaseNotes/21.rst +++ b/libcxx/docs/ReleaseNotes/21.rst @@ -43,6 +43,7 @@ Implemented Papers - P1361R2: Integration of chrono with text formatting (`Github `__) - P2255R2: A type trait to detect reference binding to temporary (implemented the type traits only) (`Github `__) - P2372R3: Fixing locale handling in chrono formatters (`Github `__) +- P0448R4: A ``strstream`` replacement using ``span`` as buffer (`Github `__) - P2562R1: ``constexpr`` Stable Sorting (`Github `__) - P0472R3: Put std::monostate in (`Github `__) - P1222R4: A Standard ``flat_set`` (`Github `__) From 580c9398926ca53d88aebbc25e9f2e06c416c1e7 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 13 Feb 2025 15:47:53 +0200 Subject: [PATCH 088/120] Try to fix CI --- libcxx/modules/std.cppm.in | 2 ++ libcxx/utils/libcxx/header_information.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index 4e927f88722f0..4338361072af6 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -101,6 +101,8 @@ module; #include #include # include +#endif +#if _LIBCPP_HAS_LOCALIZATION # include #include #include diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py index d06271a7908cc..e6a8fd53a1e0a 100644 --- a/libcxx/utils/libcxx/header_information.py +++ b/libcxx/utils/libcxx/header_information.py @@ -169,7 +169,6 @@ def __hash__(self) -> int: "inplace_vector", "linalg", "rcu", - "spanstream", "stacktrace", "stdfloat", "text_encoding", From dd045289e416adefa621f049d7f081bf512d8c03 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 13 Feb 2025 16:08:26 +0200 Subject: [PATCH 089/120] Try to fix CI --- libcxx/include/spanstream | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index d4067106b4973..fd5639e5b0f10 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -54,9 +54,11 @@ // clang-format on +#if __cplusplus > 201103L + #include <__config> -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) +#if _LIBCPP_HAS_LOCALIZATION # include <__concepts/convertible_to.h> # include <__fwd/spanstream.h> @@ -455,10 +457,12 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // !_LIBCPP_HAS_NO_LOCALIZATION +#endif // _LIBCPP_HAS_LOCALIZATION #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) # include #endif +#endif // __cplusplus > 201103L + #endif // _LIBCPP_SPANSTREAM From 520cbe629d6e9b1a0b180eeae3bf98bcee91d452 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 13 Feb 2025 16:15:30 +0200 Subject: [PATCH 090/120] Fix formatting --- libcxx/include/spanstream | 72 +++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index fd5639e5b0f10..8895aa791e175 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -56,34 +56,34 @@ #if __cplusplus > 201103L -#include <__config> - -#if _LIBCPP_HAS_LOCALIZATION - -# include <__concepts/convertible_to.h> -# include <__fwd/spanstream.h> -# include <__memory/addressof.h> -# include <__ranges/concepts.h> -# include <__utility/cmp.h> -# include <__utility/forward.h> -# include <__utility/move.h> -# include <__utility/swap.h> -# include -# include -# include -# include -# include - -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -# endif +# include <__config> + +# if _LIBCPP_HAS_LOCALIZATION + +# include <__concepts/convertible_to.h> +# include <__fwd/spanstream.h> +# include <__memory/addressof.h> +# include <__ranges/concepts.h> +# include <__utility/cmp.h> +# include <__utility/forward.h> +# include <__utility/move.h> +# include <__utility/swap.h> +# include +# include +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif _LIBCPP_PUSH_MACROS -# include <__undef_macros> +# include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD -# if _LIBCPP_STD_VER >= 23 +# if _LIBCPP_STD_VER >= 23 // Class template basic_spanbuf [spanbuf] @@ -245,9 +245,9 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_spanbuf<_CharT, _Traits>& __x, basic_spanb } using std::spanbuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wspanbuf; -# endif +# endif // Class template basic_ispanstream [ispanstream] @@ -323,9 +323,9 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_ispanstream<_CharT, _Traits>& __x, basic_i } using std::ispanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wispanstream; -# endif +# endif // Class template basic_ospanstream [ospanstream] @@ -386,9 +386,9 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_ospanstream<_CharT, _Traits>& __x, basic_o } using std::ospanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wospanstream; -# endif +# endif template class _LIBCPP_TEMPLATE_VIS basic_spanstream : public basic_iostream<_CharT, _Traits> { @@ -447,21 +447,21 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_spanstream<_CharT, _Traits>& __x, basic_sp } using std::spanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using std::wspanstream; -# endif +# endif -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // _LIBCPP_HAS_LOCALIZATION +# endif // _LIBCPP_HAS_LOCALIZATION -#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) -# include -#endif +# if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) +# include +# endif #endif // __cplusplus > 201103L From 94d573a28d2d3b0a6f360981cf208b68fbe5c140 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 13 Feb 2025 16:56:41 +0200 Subject: [PATCH 091/120] Try to fix CI --- libcxx/include/__fwd/spanstream.h | 2 +- libcxx/include/spanstream | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__fwd/spanstream.h b/libcxx/include/__fwd/spanstream.h index f5ff2ad2c9cfc..9e52ac9f3472e 100644 --- a/libcxx/include/__fwd/spanstream.h +++ b/libcxx/include/__fwd/spanstream.h @@ -34,7 +34,7 @@ using ispanstream = basic_ispanstream; using ospanstream = basic_ospanstream; using spanstream = basic_spanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# if _LIBCPP_HAS_WIDE_CHARACTERS using wspanbuf = basic_spanbuf; using wispanstream = basic_ispanstream; using wospanstream = basic_ospanstream; diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 8895aa791e175..85ddf797e1fac 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -54,7 +54,8 @@ // clang-format on -#if __cplusplus > 201103L +#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) +#else # include <__config> @@ -463,6 +464,6 @@ _LIBCPP_POP_MACROS # include # endif -#endif // __cplusplus > 201103L +#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) #endif // _LIBCPP_SPANSTREAM From 11d7a0ed05b1bc51d11b792b4bade5acb4eb6950 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 13 Feb 2025 18:50:25 +0200 Subject: [PATCH 092/120] Try to fix CI --- libcxx/include/spanstream | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 85ddf797e1fac..9f3b47c3d722e 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -246,7 +246,7 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_spanbuf<_CharT, _Traits>& __x, basic_spanb } using std::spanbuf; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# if _LIBCPP_HAS_WIDE_CHARACTERS using std::wspanbuf; # endif @@ -324,7 +324,7 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_ispanstream<_CharT, _Traits>& __x, basic_i } using std::ispanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# if _LIBCPP_HAS_WIDE_CHARACTERS using std::wispanstream; # endif @@ -387,7 +387,7 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_ospanstream<_CharT, _Traits>& __x, basic_o } using std::ospanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# if _LIBCPP_HAS_WIDE_CHARACTERS using std::wospanstream; # endif @@ -448,7 +448,7 @@ _LIBCPP_HIDE_FROM_ABI void swap(basic_spanstream<_CharT, _Traits>& __x, basic_sp } using std::spanstream; -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# if _LIBCPP_HAS_WIDE_CHARACTERS using std::wspanstream; # endif From 78c7e429cae1187ea23b8f10a50378f6b9921251 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 16 Feb 2025 11:53:06 +0200 Subject: [PATCH 093/120] Try to fix CI --- libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx23.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx26.csv | 1 - 7 files changed, 7 deletions(-) diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index 52907ade550a1..4fb468d73333c 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -1957,7 +1957,6 @@ spanstream limits spanstream locale spanstream memory spanstream mutex -spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 52907ade550a1..4fb468d73333c 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -1957,7 +1957,6 @@ spanstream limits spanstream locale spanstream memory spanstream mutex -spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 24aba8774f082..651fa53bbeb3c 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -1996,7 +1996,6 @@ spanstream limits spanstream locale spanstream memory spanstream mutex -spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index 16c0235061eff..cc081145b3508 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -2010,7 +2010,6 @@ spanstream limits spanstream locale spanstream memory spanstream mutex -spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index af671adbfd223..5b536b49298ca 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -2028,7 +2028,6 @@ spanstream limits spanstream locale spanstream memory spanstream mutex -spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index 4be448b09d629..e0b2f5b145207 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -910,7 +910,6 @@ spanstream iostream spanstream istream spanstream limits spanstream locale -spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 6ff0a31985539..40979359dde0b 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -896,7 +896,6 @@ spanstream iostream spanstream istream spanstream limits spanstream locale -spanstream new spanstream optional spanstream ostream spanstream print From 687ea98b129e1b80fdae6038947f313a8c0ecfae Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 16 Feb 2025 12:09:34 +0200 Subject: [PATCH 094/120] Try to fix CI --- libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index 4fb468d73333c..52907ade550a1 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -1957,6 +1957,7 @@ spanstream limits spanstream locale spanstream memory spanstream mutex +spanstream new spanstream optional spanstream ostream spanstream print From e20437367a943eb82acc82b9809a9be87e833e20 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 16 Feb 2025 15:27:56 +0200 Subject: [PATCH 095/120] Try to fix CI --- libcxx/include/spanstream | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 9f3b47c3d722e..62f97fc2c35a7 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -55,6 +55,7 @@ // clang-format on #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) +# include <__cxx03/__config> #else # include <__config> From c07da7d4d95323b42b1099d4a53f9e6668d942f8 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 16 Feb 2025 16:58:23 +0200 Subject: [PATCH 096/120] Try to fix transitive includes --- libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 + 3 files changed, 3 insertions(+) diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 4fb468d73333c..52907ade550a1 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -1957,6 +1957,7 @@ spanstream limits spanstream locale spanstream memory spanstream mutex +spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 651fa53bbeb3c..24aba8774f082 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -1996,6 +1996,7 @@ spanstream limits spanstream locale spanstream memory spanstream mutex +spanstream new spanstream optional spanstream ostream spanstream print diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index cc081145b3508..16c0235061eff 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -2010,6 +2010,7 @@ spanstream limits spanstream locale spanstream memory spanstream mutex +spanstream new spanstream optional spanstream ostream spanstream print From 6c2ae110716cd63b89933854855bd354c0e2b9e5 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 16 Feb 2025 18:05:10 +0200 Subject: [PATCH 097/120] Try to fix transitive includes --- libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index 5b536b49298ca..af671adbfd223 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -2028,6 +2028,7 @@ spanstream limits spanstream locale spanstream memory spanstream mutex +spanstream new spanstream optional spanstream ostream spanstream print From 80e025b1e643abd7207484becd47515b9b33f9cd Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Mon, 10 Mar 2025 17:30:07 +0200 Subject: [PATCH 098/120] Updated `spanstream` tests REQUIRES condition --- .../span.streams/ispanstream/inherited.stream.ops.pass.cpp | 2 +- .../ispanstream/ispanstream.cons/assign.move.pass.cpp | 2 +- .../ispanstream/ispanstream.cons/ctor.move.pass.cpp | 2 +- .../span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp | 2 +- .../ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp | 2 +- .../ispanstream/ispanstream.general/nothing_to_do.pass.cpp | 2 +- .../span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp | 2 +- .../span.streams/ispanstream/ispanstream.members/span.pass.cpp | 2 +- .../ispanstream/ispanstream.members/span.span.pass.cpp | 2 +- .../span.streams/ispanstream/ispanstream.swap/swap.pass.cpp | 2 +- .../ispanstream/ispanstream.swap/swap_nonmember.pass.cpp | 2 +- .../span.streams/ispanstream/types.compile.pass.cpp | 2 +- .../span.streams/ospanstream/inherited.stream.ops.pass.cpp | 2 +- .../ospanstream/ospanstream.cons/assign.move.pass.cpp | 2 +- .../ospanstream/ospanstream.cons/ctor.move.pass.cpp | 2 +- .../ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp | 2 +- .../ospanstream/ospanstream.general/nothing_to_do.pass.cpp | 2 +- .../span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp | 2 +- .../span.streams/ospanstream/ospanstream.members/span.pass.cpp | 2 +- .../ospanstream/ospanstream.members/span.span.pass.cpp | 2 +- .../span.streams/ospanstream/ospanstream.swap/swap.pass.cpp | 2 +- .../ospanstream/ospanstream.swap/swap_nonmember.pass.cpp | 2 +- .../span.streams/ospanstream/types.compile.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.assign/swap.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.cons/default.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.cons/mode.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.cons/move.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.members/span.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.members/span.span.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp | 2 +- .../span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 2 +- .../input.output/span.streams/spanbuf/types.compile.pass.cpp | 2 +- .../span.streams/spanstream/inherited.stream.ops.pass.cpp | 2 +- .../spanstream/spanstream.cons/assign.move.pass.cpp | 2 +- .../span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp | 2 +- .../spanstream/spanstream.cons/ctor.span.mode.pass.cpp | 2 +- .../spanstream/spanstream.general/nothing_to_do.pass.cpp | 2 +- .../span.streams/spanstream/spanstream.members/rdbuf.pass.cpp | 2 +- .../span.streams/spanstream/spanstream.members/span.pass.cpp | 2 +- .../spanstream/spanstream.members/span.span.pass.cpp | 2 +- .../span.streams/spanstream/spanstream.swap/swap.pass.cpp | 2 +- .../spanstream/spanstream.swap/swap_nonmember.pass.cpp | 2 +- .../input.output/span.streams/spanstream/types.compile.pass.cpp | 2 +- 48 files changed, 48 insertions(+), 48 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp index 2d73c9a6e244f..3c61ed4be478c 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp index 28332bcce6337..ce70b354fd1ec 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp index 4e8f5756e47a9..6c0756eb3c372 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index 1df6ab263b9c0..6a9e5ad0a72f0 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index 98c8c83378adc..adf340c28d614 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp index 4a307014fa0f7..10fc760544714 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.general/nothing_to_do.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp index 67924a5e66030..177759c4b97c5 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp index 381c5b601e053..8e12df37c6afe 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp index 3a139529c6a7c..cb838274ff00a 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp index ba50931961049..a67c329e482ce 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp index 23f4418f778ca..d17d048519391 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index e18691d19acaf..07654247f3b51 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp index fec68424cf7b3..8b55b9761bebc 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 5421cf05f690c..7d2343c5a977e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index 6a1c38ff7b383..bf02a68e2bce7 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp index d4cbd5883d5c0..3d8771c9ff325 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp index 6f9497040a897..158afc6b33563 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.general/nothing_to_do.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp index 2f9dc0a5a4025..49d5bce3d5576 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp index 82d4fa9be1125..4e3bab9792a9a 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp index 1ae821b26bc2b..1fddfd7498ad6 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp index bed53cf086577..86afc1d8021bd 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp index cf9c146945cc8..2fd563d883aca 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index 92eaf4ada2f80..4499404573ac6 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp index 9dc7233942071..270a94076f73a 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index 0b906c8a6a4fc..1f4a4d33d50a5 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index 9b9f78928a5af..6954538d89b7e 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp index e1c6604b1bceb..797e0110fe441 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index 4acc5d7d862ba..370c79b92d7eb 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index 06f912425b756..874b9f1900c2f 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index c719c9caa9865..cc88f7840427a 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp index fc746f4af7c76..21fde6bfd26df 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.general/nothing_to_do.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 3eb51e6076e60..4dabf029a2509 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index 510b5f9d70f4c..b6721965e6f81 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp index 006bd0786ccc8..b3b1b3a7dfb70 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekoff.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp index a7e9584ed2fd7..eae307a769bfc 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/seekpos.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index 254f4cdc40c0c..e158cbb6503a6 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp index 7ffbb9d24eab9..dbed1792b7ab0 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/types.compile.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp index 0744e7e4e47e9..8e2b74b25ed58 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/inherited.stream.ops.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index aacc0a6fbed43..5beef47dad17d 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index ec68018fc5a82..acf7bdf1324f2 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 958af252af3fe..0f1d0b86287d6 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp index 8677bb6d0906d..db651e1bd900c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.general/nothing_to_do.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp index 9cc0db4b9dc9a..1c2f4e76e727c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp index 5eedf9e01d9ec..aa2f64dc1de1b 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp index 77ac8dbfaa2e4..bc997a84e2bc1 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp index 4225e80a4da2f..6ec39470ae6e8 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp index baba48cbb1d0b..79468d2364f51 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // diff --git a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp index 83f6b235ae913..6562841558463 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/types.compile.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// REQUIRES: std-at-least-c++23 // From 8ce2b8eed1c6d9288b563c6dd0961dda26f510d6 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 19 Mar 2025 13:09:53 +0200 Subject: [PATCH 099/120] Cleanup `` --- libcxx/include/spanstream | 10 +-- .../ospanstream/inherited.stream.ops.pass.cpp | 61 ++++++++++++++++++- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 62f97fc2c35a7..62d00dabc6848 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -237,8 +237,8 @@ protected: } private: - ios_base::openmode __mode_; // exposition only - std::span<_CharT> __buf_; // exposition only + ios_base::openmode __mode_; + std::span<_CharT> __buf_; }; template @@ -316,7 +316,7 @@ public: } private: - basic_spanbuf<_CharT, _Traits> __sb_; // exposition only + basic_spanbuf<_CharT, _Traits> __sb_; }; template @@ -379,7 +379,7 @@ public: _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } private: - basic_spanbuf<_CharT, _Traits> __sb_; // exposition only + basic_spanbuf<_CharT, _Traits> __sb_; }; template @@ -440,7 +440,7 @@ public: _LIBCPP_HIDE_FROM_ABI void span(std::span<_CharT> __s) noexcept { rdbuf()->span(__s); } private: - basic_spanbuf<_CharT, _Traits> __sb_; // exposition only + basic_spanbuf<_CharT, _Traits> __sb_; }; template diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp index 8b55b9761bebc..10298cb50c32a 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp @@ -21,6 +21,9 @@ #include #include #include +#include + +#include #include "constexpr_char_traits.h" #include "test_macros.h" @@ -40,11 +43,11 @@ void test() { // Create a std::span test value CharT arr[arrSize]{}; initialize_array_from_string_view(arr, sv); - - std::span sp{arr}; + std::vector vec(arr, arr + arrSize); // `std::span` + Mode: default (`out`) { + std::span sp{arr}; SpStream spSt(sp); assert(spSt); @@ -59,13 +62,65 @@ void test() { assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); + assert(spSt.span().size() == 0); + } + { + std::span sp{arr}; + SpStream spSt(sp); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + assert(spSt.span().size() == 0); + + spSt << 10; + + assert(spSt.span().size() == 2); + + spSt.clear(); + + // assert(spSt); + // assert(!spSt.bad()); + // assert(!spSt.fail()); + // assert(spSt.good()); + // assert(spSt.span().size() == 0); + + spSt << SV("gh"); + assert(spSt.span().size() == 4); + std::println(stderr, "{}", spSt.span()[0]); + std::println(stderr, "{}", arr[0]); + assert(spSt.span()[0] == '1'); + assert(arr[0] == '1'); + assert(spSt.span()[1] == '0'); + assert(arr[1] == '0'); + assert(spSt.span()[2] == 'g'); + assert(arr[2] == 'g'); + + CharT output_buffer[30]; + std::basic_ospanstream os{std::span{output_buffer}}; + + assert(os.good()); + assert(!os.fail()); + assert(!os.bad()); + os << 10 << 20 << 30; + os << SV("GH"); + assert(os.good()); + assert(!os.fail()); + assert(!os.bad()); + std::println(stderr, "{}", os.span()[0]); + std::println(stderr, "{}", output_buffer[0]); + std::println(stderr, "{}", os.span().size()); + std::println(stderr, "{}", os.span()[6]); + std::println(stderr, "{}", output_buffer[7]); + assert(false); } } int main(int, char**) { test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); + // test(); #endif return 0; From 97f19f6b6e467c09d926933d758b0b24b7fbcc19 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 21 Mar 2025 09:39:44 +0200 Subject: [PATCH 100/120] WIP - `ospanstream` --- .../input.output/span.streams/helper_macros.h | 16 ++++ .../ospanstream/inherited.stream.ops.pass.cpp | 83 +++++++------------ 2 files changed, 48 insertions(+), 51 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/helper_macros.h b/libcxx/test/std/input.output/span.streams/helper_macros.h index 679686eaa41a8..7a27fba60d876 100644 --- a/libcxx/test/std/input.output/span.streams/helper_macros.h +++ b/libcxx/test/std/input.output/span.streams/helper_macros.h @@ -9,8 +9,24 @@ #ifndef TEST_STD_INPUTOUTPUT_SPANSTREAMS_MACROS_H #define TEST_STD_INPUTOUTPUT_SPANSTREAMS_MACROS_H +#include + #include "make_string.h" +#ifndef TEST_HAS_NO_WIDE_CHARACTERS +# define CH(C) \ + (std::is_same_v ? L##C \ + : std::is_same_v ? u8##C \ + : std::is_same_v ? u##C \ + : std::is_same_v ? U##C \ + : C) +#else +# define CH(C) \ + (std::is_same_v ? u8##C \ + : std::is_same_v ? u##C \ + : std::is_same_v ? U##C \ + : C) +#endif // TEST_HAS_NO_WIDE_CHARACTERS #define CS(S) MAKE_CSTRING(CharT, S) #define ST(S, a) std::basic_string(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S), a) #define SV(S) std::basic_string_view(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S)) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp index 10298cb50c32a..605767d8a1dfa 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp @@ -21,9 +21,6 @@ #include #include #include -#include - -#include #include "constexpr_char_traits.h" #include "test_macros.h" @@ -43,11 +40,10 @@ void test() { // Create a std::span test value CharT arr[arrSize]{}; initialize_array_from_string_view(arr, sv); - std::vector vec(arr, arr + arrSize); + std::span sp{arr}; // `std::span` + Mode: default (`out`) { - std::span sp{arr}; SpStream spSt(sp); assert(spSt); @@ -56,71 +52,56 @@ void test() { assert(spSt.good()); assert(spSt.span().size() == 0); - spSt.clear(); + // Check underlying buffer + assert(arr[0] == CH('z')); + assert(arr[1] == CH('m')); + assert(arr[2] == CH('t')); + + spSt << SV("snt"); + + assert(spSt.span().size() == 3); + + assert(spSt.span()[0] == CH('s')); + assert(spSt.span()[1] == CH('n')); + assert(spSt.span()[2] == CH('t')); + // Check underlying buffer + assert(arr[0] == CH('s')); + assert(arr[1] == CH('n')); + assert(arr[2] == CH('t')); assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); - assert(spSt.span().size() == 0); - } - { - std::span sp{arr}; - SpStream spSt(sp); + + spSt << 71; + + assert(spSt.span().size() == 5); + + assert(spSt.span()[3] == CH('7')); + assert(spSt.span()[4] == CH('1')); + // Check underlying buffer + assert(arr[3] == CH('7')); + assert(arr[4] == CH('1')); assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); assert(spSt.good()); - assert(spSt.span().size() == 0); - - spSt << 10; - - assert(spSt.span().size() == 2); spSt.clear(); - // assert(spSt); - // assert(!spSt.bad()); - // assert(!spSt.fail()); - // assert(spSt.good()); - // assert(spSt.span().size() == 0); - - spSt << SV("gh"); - assert(spSt.span().size() == 4); - std::println(stderr, "{}", spSt.span()[0]); - std::println(stderr, "{}", arr[0]); - assert(spSt.span()[0] == '1'); - assert(arr[0] == '1'); - assert(spSt.span()[1] == '0'); - assert(arr[1] == '0'); - assert(spSt.span()[2] == 'g'); - assert(arr[2] == 'g'); - - CharT output_buffer[30]; - std::basic_ospanstream os{std::span{output_buffer}}; - - assert(os.good()); - assert(!os.fail()); - assert(!os.bad()); - os << 10 << 20 << 30; - os << SV("GH"); - assert(os.good()); - assert(!os.fail()); - assert(!os.bad()); - std::println(stderr, "{}", os.span()[0]); - std::println(stderr, "{}", output_buffer[0]); - std::println(stderr, "{}", os.span().size()); - std::println(stderr, "{}", os.span()[6]); - std::println(stderr, "{}", output_buffer[7]); - assert(false); + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); } } int main(int, char**) { test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - // test(); + test(); #endif return 0; From 672a2d356c6b2741fb542ba0a5cbc50a0a9d5eea Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 21 Mar 2025 09:46:37 +0200 Subject: [PATCH 101/120] Removed tests for `char8_t`, `char16_t`, `char32_t` as unsupported --- .../ispanstream.cons/assign.move.pass.cpp | 9 --------- .../ispanstream.cons/ctor.move.pass.cpp | 9 --------- .../ispanstream.cons/ctor.ros.pass.cpp | 9 --------- .../ispanstream.cons/ctor.span.mode.pass.cpp | 9 --------- .../ispanstream.members/rdbuf.pass.cpp | 9 --------- .../ispanstream.members/span.pass.cpp | 9 --------- .../ispanstream.members/span.span.pass.cpp | 9 --------- .../ispanstream/ispanstream.swap/swap.pass.cpp | 9 --------- .../ispanstream.swap/swap_nonmember.pass.cpp | 9 --------- .../ispanstream/types.compile.pass.cpp | 9 --------- .../ospanstream.cons/assign.move.pass.cpp | 9 --------- .../ospanstream.cons/ctor.move.pass.cpp | 9 --------- .../ospanstream.cons/ctor.span.mode.pass.cpp | 18 ------------------ .../ospanstream.members/rdbuf.pass.cpp | 9 --------- .../ospanstream.members/span.pass.cpp | 9 --------- .../ospanstream.members/span.span.pass.cpp | 9 --------- .../ospanstream/ospanstream.swap/swap.pass.cpp | 9 --------- .../ospanstream.swap/swap_nonmember.pass.cpp | 9 --------- .../ospanstream/types.compile.pass.cpp | 9 --------- .../spanstream.cons/assign.move.pass.cpp | 9 --------- .../spanstream.cons/ctor.move.pass.cpp | 9 --------- .../spanstream.cons/ctor.span.mode.pass.cpp | 18 ------------------ 22 files changed, 216 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp index ce70b354fd1ec..28707914d5b5c 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -120,14 +120,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp index 6c0756eb3c372..715c5b84281dc 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp @@ -120,14 +120,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index 6a9e5ad0a72f0..a86772d6b5bc6 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -98,14 +98,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index adf340c28d614..274cdf0a31654 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -142,14 +142,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp index 177759c4b97c5..f96327774d037 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp @@ -78,14 +78,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp index 8e12df37c6afe..750f211471363 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp @@ -79,14 +79,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp index cb838274ff00a..f2ff31da99f02 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp @@ -99,14 +99,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp index a67c329e482ce..c3fa7bb145367 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp @@ -130,14 +130,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp index d17d048519391..b135e91aea982 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp @@ -126,14 +126,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp index 07654247f3b51..b815f4abc34db 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/types.compile.pass.cpp @@ -70,15 +70,6 @@ void test() { test(); test>(); #endif - -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); } // Aliases diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 7d2343c5a977e..8ccf94c85cbcc 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -123,14 +123,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index bf02a68e2bce7..46bcfbbb56e41 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -123,14 +123,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp index 3d8771c9ff325..ebf97cfd1b6b8 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp @@ -125,15 +125,6 @@ int main(int, char**) { test_sfinae>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test_sfinae(); - test_sfinae>(); -#endif - test_sfinae(); - test_sfinae>(); - test_sfinae(); - test_sfinae>(); - #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif @@ -145,14 +136,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp index 49d5bce3d5576..efed374309236 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp @@ -80,14 +80,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp index 4e3bab9792a9a..b5d8ae21d4ea2 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp @@ -81,14 +81,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp index 1fddfd7498ad6..07f3432904acb 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp @@ -101,14 +101,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp index 86afc1d8021bd..c821ae439dbf6 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp @@ -134,14 +134,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp index 2fd563d883aca..f35db4936dd87 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp @@ -130,14 +130,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp index 4499404573ac6..d0d966521670f 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/types.compile.pass.cpp @@ -70,15 +70,6 @@ void test() { test(); test>(); #endif - -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); } // Aliases diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index 5beef47dad17d..60507b2ae7393 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -136,14 +136,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index acf7bdf1324f2..74280970b999e 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -136,14 +136,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 0f1d0b86287d6..0b53aa926dade 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -133,15 +133,6 @@ int main(int, char**) { test_sfinae>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test_sfinae(); - test_sfinae>(); -#endif - test_sfinae(); - test_sfinae>(); - test_sfinae(); - test_sfinae>(); - #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif @@ -153,14 +144,5 @@ int main(int, char**) { test>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test(); - test>(); -#endif - test(); - test>(); - test(); - test>(); - return 0; } From 5e75d2766f960b615308e044f9d0c2e97849ca11 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 22 Mar 2025 07:50:57 +0200 Subject: [PATCH 102/120] WIP - test `ospanstream` inherited stream ops --- .../input.output/span.streams/helper_macros.h | 15 ++---- .../ospanstream/inherited.stream.ops.pass.cpp | 50 ++++++++++++++++--- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/helper_macros.h b/libcxx/test/std/input.output/span.streams/helper_macros.h index 7a27fba60d876..fdbfbe68220bf 100644 --- a/libcxx/test/std/input.output/span.streams/helper_macros.h +++ b/libcxx/test/std/input.output/span.streams/helper_macros.h @@ -13,19 +13,12 @@ #include "make_string.h" +// Helper macros for creating strings and string views + #ifndef TEST_HAS_NO_WIDE_CHARACTERS -# define CH(C) \ - (std::is_same_v ? L##C \ - : std::is_same_v ? u8##C \ - : std::is_same_v ? u##C \ - : std::is_same_v ? U##C \ - : C) +# define CH(C) (std::is_same_v ? L##C : C) #else -# define CH(C) \ - (std::is_same_v ? u8##C \ - : std::is_same_v ? u##C \ - : std::is_same_v ? U##C \ - : C) +# define CH(C) C #endif // TEST_HAS_NO_WIDE_CHARACTERS #define CS(S) MAKE_CSTRING(CharT, S) #define ST(S, a) std::basic_string(MAKE_CSTRING(CharT, S), MKSTR_LEN(CharT, S), a) diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp index 605767d8a1dfa..199c4849261bb 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp @@ -14,7 +14,7 @@ // class basic_spanstream // : public basic_iostream { -// Test stream operations inherited from `basic_istream` and `basic_ostream` +// Test stream operations inherited from `basic_ostream` #include #include @@ -37,6 +37,9 @@ void test() { constexpr auto arrSize{30UZ}; assert(sv.size() < arrSize); + constexpr std::basic_string_view sv2{SV("This string should overflow! This string should overflow!")}; + assert(sv2.size() >= arrSize); + // Create a std::span test value CharT arr[arrSize]{}; initialize_array_from_string_view(arr, sv); @@ -44,6 +47,7 @@ void test() { // `std::span` + Mode: default (`out`) { + // Construct stream SpStream spSt(sp); assert(spSt); @@ -52,11 +56,11 @@ void test() { assert(spSt.good()); assert(spSt.span().size() == 0); - // Check underlying buffer - assert(arr[0] == CH('z')); + assert(arr[0] == CH('z')); // Check underlying buffer assert(arr[1] == CH('m')); assert(arr[2] == CH('t')); + // Write to stream spSt << SV("snt"); assert(spSt.span().size() == 3); @@ -64,8 +68,8 @@ void test() { assert(spSt.span()[0] == CH('s')); assert(spSt.span()[1] == CH('n')); assert(spSt.span()[2] == CH('t')); - // Check underlying buffer - assert(arr[0] == CH('s')); + + assert(arr[0] == CH('s')); // Check underlying buffer assert(arr[1] == CH('n')); assert(arr[2] == CH('t')); @@ -80,8 +84,8 @@ void test() { assert(spSt.span()[3] == CH('7')); assert(spSt.span()[4] == CH('1')); - // Check underlying buffer - assert(arr[3] == CH('7')); + + assert(arr[3] == CH('7')); // Check underlying buffer assert(arr[4] == CH('1')); assert(spSt); @@ -89,8 +93,40 @@ void test() { assert(!spSt.fail()); assert(spSt.good()); + spSt.put(CH('!')); + + assert(spSt.span().size() == 6); + + assert(spSt.span()[5] == CH('!')); + + assert(arr[5] == CH('!')); // Check underlying buffer + + spSt.write(CS("?#?"), 1); + + assert(spSt.span().size() == 7); + + assert(spSt.span()[6] == CH('?')); + + assert(arr[6] == CH('?')); // Check underlying buffer + + // Write to stream with overflow + spSt << sv2; + + assert(spSt.span().size() == 30); + + assert(!spSt); + assert(spSt.bad()); + assert(spSt.fail()); + assert(!spSt.good()); + + assert(spSt.tellp() == 30); + + // Clear stream + spSt.seekp(0); spSt.clear(); + assert(spSt.span().size() == 0); + assert(spSt); assert(!spSt.bad()); assert(!spSt.fail()); From 49ccc7f3654167edd34394a3567688d22eb1c1f0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 28 Mar 2025 11:07:40 +0200 Subject: [PATCH 103/120] Mass test cleanup --- .../ispanstream/inherited.stream.ops.pass.cpp | 236 +++++------------- .../ispanstream.cons/assign.move.pass.cpp | 42 +--- .../ispanstream.cons/ctor.move.pass.cpp | 42 +--- .../ispanstream.cons/ctor.ros.pass.cpp | 16 +- .../ispanstream.cons/ctor.span.mode.pass.cpp | 59 ++--- .../ispanstream.members/rdbuf.pass.cpp | 13 +- .../ispanstream.members/span.pass.cpp | 17 -- .../ispanstream.members/span.span.pass.cpp | 33 --- .../ispanstream.swap/swap.pass.cpp | 49 ---- .../ispanstream.swap/swap_nonmember.pass.cpp | 33 --- .../ospanstream/inherited.stream.ops.pass.cpp | 12 +- .../ospanstream.cons/assign.move.pass.cpp | 27 -- .../ospanstream.cons/ctor.move.pass.cpp | 27 -- .../ospanstream.cons/ctor.span.mode.pass.cpp | 20 -- .../ospanstream.members/rdbuf.pass.cpp | 11 - .../ospanstream.members/span.pass.cpp | 10 - .../ospanstream.members/span.span.pass.cpp | 8 - .../ospanstream.swap/swap.pass.cpp | 33 --- .../ospanstream.swap/swap_nonmember.pass.cpp | 33 --- .../spanbuf.assign/assign.move.pass.cpp | 56 +---- .../spanbuf/spanbuf.assign/swap.pass.cpp | 33 +-- .../spanbuf.assign/swap_nonmember.pass.cpp | 32 +-- .../spanbuf/spanbuf.cons/default.pass.cpp | 1 - .../spanbuf/spanbuf.cons/mode.pass.cpp | 10 +- .../spanbuf/spanbuf.cons/move.pass.cpp | 60 +---- .../spanbuf/spanbuf.cons/span.mode.pass.cpp | 45 +--- .../spanbuf/spanbuf.members/span.pass.cpp | 13 +- .../spanbuf.members/span.span.pass.cpp | 16 +- .../spanbuf/spanbuf.virtuals/setbuf.pass.cpp | 18 +- .../spanstream.cons/assign.move.pass.cpp | 23 +- .../spanstream.cons/ctor.move.pass.cpp | 21 +- .../spanstream.cons/ctor.span.mode.pass.cpp | 19 +- .../spanstream.members/rdbuf.pass.cpp | 13 +- .../spanstream.members/span.pass.cpp | 12 +- .../spanstream.members/span.span.pass.cpp | 18 +- .../spanstream/spanstream.swap/swap.pass.cpp | 34 +-- .../spanstream.swap/swap_nonmember.pass.cpp | 31 +-- 37 files changed, 180 insertions(+), 996 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp index 3c61ed4be478c..331764c641a4c 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -14,12 +14,11 @@ // class basic_spanstream // : public basic_iostream { -// Test stream operations inherited from `basic_istream` and `basic_ostream` +// Test stream operations inherited from `basic_istream` #include #include #include -#include #include #include "constexpr_char_traits.h" @@ -29,206 +28,101 @@ #include "../helper_macros.h" #include "../helper_types.h" +#include // REMOVE ME +#include // REMOVE ME + +template +void test_ispanstream(std::basic_ispanstream& spSt, std::size_t size) { + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + assert(spSt.span().size() == size); + + // Read from stream + std::basic_string str1; + spSt >> str1; + int i1; + spSt >> i1; + std::basic_string str2; + spSt >> str2; + int i2; + spSt >> i2; + std::basic_string str3; + spSt >> str3; + int i3; + spSt >> i3; + + assert(str1 == CS("zmt")); + assert(i1 == 94); + assert(str2 == CS("hkt")); + assert(i2 == 82); + assert(str3 == CS("pir")); + assert(i3 == 43); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); + + spSt.clear(); + + assert(spSt); + assert(!spSt.bad()); + assert(!spSt.fail()); + assert(spSt.good()); +} + template > void test() { using SpStream = std::basic_ispanstream; constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; - constexpr auto arrSize{30UZ}; - assert(sv.size() < arrSize); + assert(sv.size() < 30UZ); // Create a std::span test value - CharT arr[arrSize]{}; + CharT arr[30UZ]{}; initialize_array_from_string_view(arr, sv); std::span sp{arr}; // Create a "Read Only Sequence" test value - CharT rosArr[arrSize]{}; + CharT rosArr[30UZ]{}; initialize_array_from_string_view(rosArr, sv); - ReadOnlySpan ros{rosArr}; - assert(ros.size() == arrSize); + ReadOnlySpan ros{rosArr}; + assert(ros.size() == 30UZ); - // `std::span` + Mode: default (`in`) + // std::span` + Mode: default (`in`) { SpStream spSt(sp); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - assert(spSt.span().size() == arrSize); - - // Read from stream - std::basic_string str1; - spSt >> str1; - int i1; - spSt >> i1; - std::basic_string str2; - spSt >> str2; - int i2; - spSt >> i2; - std::basic_string str3; - spSt >> str3; - int i3; - spSt >> i3; - - assert(str1 == CS("zmt")); - assert(i1 == 94); - assert(str2 == CS("hkt")); - assert(i2 == 82); - assert(str3 == CS("pir")); - assert(i3 == 43); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - - spSt.clear(); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); + test_ispanstream(spSt, 30UZ); } - // `ReadOnlySpan` + Mode: default (`in`) + // std::span` + Mode: explicit `in` { - SpStream spSt(sp); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - assert(spSt.span().size() == arrSize); - - // Read from stream - std::basic_string str1; - spSt >> str1; - int i1; - spSt >> i1; - std::basic_string str2; - spSt >> str2; - int i2; - spSt >> i2; - std::basic_string str3; - spSt >> str3; - int i3; - spSt >> i3; - - assert(str1 == CS("zmt")); - assert(i1 == 94); - assert(str2 == CS("hkt")); - assert(i2 == 82); - assert(str3 == CS("pir")); - assert(i3 == 43); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - - spSt.clear(); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); + SpStream spSt(sp, std::ios_base::in); + test_ispanstream(spSt, 30UZ); } - // `std::span` + Mode: `ate` + // `ReadOnlySpan` + Mode: default (`in`) { - SpStream spSt(sp, std::ios_base::ate); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - assert(spSt.span().size() == arrSize); - - // Read from stream - std::basic_string str1; - spSt >> str1; - int i1; - spSt >> i1; - std::basic_string str2; - spSt >> str2; - int i2; - spSt >> i2; - std::basic_string str3; - spSt >> str3; - int i3; - spSt >> i3; - - assert(str1 == CS("zmt")); - assert(i1 == 94); - assert(str2 == CS("hkt")); - assert(i2 == 82); - assert(str3 == CS("pir")); - assert(i3 == 43); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - - spSt.clear(); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); + SpStream spSt(ros); + test_ispanstream(spSt, 30UZ); } - // `ReadOnlySpan` + Mode: `ate` + { SpStream spSt(sp, std::ios_base::ate); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - assert(spSt.span().size() == arrSize); - - // Read from stream - std::basic_string str1; - spSt >> str1; - int i1; - spSt >> i1; - std::basic_string str2; - spSt >> str2; - int i2; - spSt >> i2; - std::basic_string str3; - spSt >> str3; - int i3; - spSt >> i3; - - assert(str1 == CS("zmt")); - assert(i1 == 94); - assert(str2 == CS("hkt")); - assert(i2 == 82); - assert(str3 == CS("pir")); - assert(i3 == 43); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); - - spSt.clear(); - - assert(spSt); - assert(!spSt.bad()); - assert(!spSt.fail()); - assert(spSt.good()); + std::println(stderr, "spSt.span().size() = {}", spSt.span().size()); + // std::println(stderr, "spSt.tellg() = {}", spSt.tellg()); + std::cerr << "spSt.tellg() = " << spSt.tellg() << std::endl; + assert(false); } } int main(int, char**) { test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); + // test(); #endif return 0; diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp index 28707914d5b5c..6276a31ca3f23 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/assign.move.pass.cpp @@ -42,68 +42,28 @@ void test() { { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode: `in` + // Mode: explicit `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - } - // Mode: `ate` - { - SpStream rhsSpSt{sp, std::ios_base::ate}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt = std::move(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt = std::move(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp index 715c5b84281dc..a79d19bff5024 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.move.pass.cpp @@ -42,68 +42,28 @@ void test() { { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::move(rhsSpSt)); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode: `in` + // Mode: explicit `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::move(rhsSpSt)); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - } - // Mode `ate` - { - SpStream rhsSpSt{sp, std::ios_base::ate}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt{std::move(rhsSpSt)}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - - // State after move - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt{std::move(rhsSpSt)}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp index a86772d6b5bc6..c7152471ea70a 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.ros.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "constexpr_char_traits.h" #include "nasty_string.h" @@ -61,7 +62,11 @@ void test() { { SpStream spSt(ros); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); + assert(spSt.span().size() == 4); + } + { + SpStream spSt(std::move(ros)); + assert(spSt.span().data() == arr); assert(spSt.span().size() == 4); } } @@ -78,15 +83,6 @@ int main(int, char**) { test_sfinae>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test_sfinae(); - test_sfinae>(); -#endif - test_sfinae(); - test_sfinae>(); - test_sfinae(); - test_sfinae>(); - #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp index 274cdf0a31654..7a813b8e8eac7 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.cons/ctor.span.mode.pass.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "constexpr_char_traits.h" @@ -53,59 +54,44 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in`) { SpStream spSt{sp}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: `in` +#ifndef TEST_HAS_NO_NASTY_STRING + // Test implicit construction from a string + if constexpr (!std::same_as) { + std::basic_string str; + { + SpStream spSt{str}; + assert(spSt.span().data() == str.data()); + assert(spSt.span().size() == 0); + } + { + SpStream spSt{std::as_const(str)}; + assert(spSt.span().data() == str.data()); + assert(spSt.span().size() == 0); + } + } +#endif + // Mode: explicit `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { SpStream spSt{std::as_const(sp), std::ios_base::in}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode `ate` - { - SpStream spSt{sp, std::ios_base::ate}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - { - SpStream spSt{std::as_const(sp), std::ios_base::ate}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - { - SpStream spSt{std::as_const(sp), std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } @@ -122,15 +108,6 @@ int main(int, char**) { test_sfinae>(); #endif -#ifndef TEST_HAS_NO_CHAR8_T - test_sfinae(); - test_sfinae>(); -#endif - test_sfinae(); - test_sfinae>(); - test_sfinae(); - test_sfinae>(); - #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp index f96327774d037..1560399c37905 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp @@ -33,35 +33,24 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in`) { SpStream spSt{sp}; assert(spSt.rdbuf()->span().data() == arr); - assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } - // Mode: `in` + // Mode: explicit `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.rdbuf()->span().data() == arr); - assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } // Mode: `ate` { SpStream spSt{sp, std::ios_base::ate}; assert(spSt.rdbuf()->span().data() == arr); - assert(!spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.rdbuf()->span().data() == arr); - assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp index 750f211471363..95b2c9d48eb38 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.pass.cpp @@ -34,35 +34,18 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` ) { SpStream spSt{sp}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: `ate` - { - SpStream spSt{sp, std::ios_base::ate}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp index f2ff31da99f02..b6341d7843106 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/span.span.pass.cpp @@ -32,57 +32,24 @@ void test() { CharT arr[4]; - std::span sp{arr}; - assert(sp.data() == arr); - assert(!sp.empty()); - assert(sp.size() == 4); - // Mode: default (`in` ) { SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: `in` { SpStream spSt{std::span{}, std::ios_base::in}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(arr); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: `ate` - { - SpStream spSt{std::span{}, std::ios_base::ate}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.span(arr); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{std::span{}, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp index c3fa7bb145367..2772e6922df05 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap.pass.cpp @@ -33,87 +33,38 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: `ate` - { - SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp index b135e91aea982..e2a8837d56399 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.swap/swap_nonmember.pass.cpp @@ -29,87 +29,54 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `ate` { SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp index 199c4849261bb..82be6cb7ac8bd 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/inherited.stream.ops.pass.cpp @@ -29,6 +29,9 @@ #include "../helper_macros.h" #include "../helper_types.h" +#include // REMOVE ME +#include // REMOVE ME + template > void test() { using SpStream = std::basic_ospanstream; @@ -109,6 +112,8 @@ void test() { assert(arr[6] == CH('?')); // Check underlying buffer + assert(spSt.tellp() == 7); + // Write to stream with overflow spSt << sv2; @@ -119,11 +124,12 @@ void test() { assert(spSt.fail()); assert(!spSt.good()); - assert(spSt.tellp() == 30); + // Test error state + assert(spSt.tellp() == -1); // Clear stream - spSt.seekp(0); spSt.clear(); + spSt.seekp(0); assert(spSt.span().size() == 0); @@ -137,7 +143,7 @@ void test() { int main(int, char**) { test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS - test(); + // test(); #endif return 0; diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp index 8ccf94c85cbcc..c4b60631e67b3 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp @@ -34,7 +34,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`out`) @@ -42,18 +41,15 @@ void test() { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `out` @@ -61,52 +57,29 @@ void test() { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt = std::move(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp index 46bcfbbb56e41..f17b83e92797b 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp @@ -34,7 +34,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`out`) @@ -42,18 +41,15 @@ void test() { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `out` @@ -61,52 +57,29 @@ void test() { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt{std::move(rhsSpSt)}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - - // Test after move - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp index ebf97cfd1b6b8..f0522059c5c5b 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.span.mode.pass.cpp @@ -52,7 +52,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`out`) @@ -60,14 +59,12 @@ void test() { SpStream spSt{sp}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode `out` @@ -75,40 +72,23 @@ void test() { SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { SpStream spSt{std::as_const(sp), std::ios_base::out}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode `ate` { SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { SpStream spSt{std::as_const(sp), std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - { - SpStream spSt{std::as_const(sp), std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp index efed374309236..dcb018ba6d50e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/rdbuf.pass.cpp @@ -33,7 +33,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`out`) @@ -41,7 +40,6 @@ void test() { SpStream spSt{sp}; assert(spSt.rdbuf()->span().data() == arr); // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } // Mode: `out` @@ -49,21 +47,12 @@ void test() { SpStream spSt{sp, std::ios_base::out}; assert(spSt.rdbuf()->span().data() == arr); // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } // Mode: `ate` { SpStream spSt{sp, std::ios_base::ate}; assert(spSt.rdbuf()->span().data() == arr); - assert(!spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.rdbuf()->span().data() == arr); - assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp index b5d8ae21d4ea2..df04324f89287 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.pass.cpp @@ -42,7 +42,6 @@ void test() { SpStream spSt{sp}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `out` @@ -50,21 +49,12 @@ void test() { SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `ate` { SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - } - // Mode: multiple - { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp index 07f3432904acb..4567080b1ccf1 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.members/span.span.pass.cpp @@ -41,50 +41,42 @@ void test() { { SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `out` { SpStream spSt{std::span{}, std::ios_base::out}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `ate` { SpStream spSt{std::span{}, std::ios_base::ate}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: multiple { SpStream spSt{std::span{}, std::ios_base::ate | std::ios_base::binary}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp index c821ae439dbf6..94a36a29d508e 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap.pass.cpp @@ -33,7 +33,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`out`) @@ -41,21 +40,17 @@ void test() { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `out` @@ -63,61 +58,33 @@ void test() { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `ate` { SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - spSt.swap(rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp index f35db4936dd87..3e1c36848e692 100644 --- a/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.swap/swap_nonmember.pass.cpp @@ -29,7 +29,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`out`) @@ -37,21 +36,17 @@ void test() { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `out` @@ -59,61 +54,33 @@ void test() { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `ate` { SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); - } - // Mode: multiple - { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; - assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 4); - - SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); - - std::swap(spSt, rhsSpSt); - assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); - assert(spSt.span().size() == 4); - assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp index 270a94076f73a..5724ba89043ee 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp @@ -161,18 +161,15 @@ void test() { SpBuf rhsSpBuf; assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `in` @@ -180,17 +177,14 @@ void test() { SpBuf rhsSpBuf{std::ios_base::in}; assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `out` @@ -198,51 +192,38 @@ void test() { SpBuf rhsSpBuf{std::ios_base::out}; assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in | std::ios_base::binary}; - assert(rhsSpBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); - + SpBuf rhsSpBuf{std::ios_base::ate}; SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: `ate` + // Mode: multiple { - SpBuf rhsSpBuf{std::ios_base::ate}; + SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in | std::ios_base::ate}; SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } } @@ -257,30 +238,25 @@ void test() { SpBuf rhsSpBuf{sp}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } // Mode `out` @@ -288,54 +264,43 @@ void test() { SpBuf rhsSpBuf{sp, std::ios_base::out}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + SpBuf rhsSpBuf{sp, std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); + assert(rhsSpBuf.span().size() == 4); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); + assert(rhsSpBuf.span().size() == 4); } // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base::ate}; + SpBuf rhsSpBuf{sp, std::ios_base : out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf = std::move(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); } } @@ -351,6 +316,7 @@ int main(int, char**) { test_postconditions(); test_postconditions>(); #endif + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp index 1f4a4d33d50a5..432e0d70c5007 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap.pass.cpp @@ -33,7 +33,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) @@ -41,41 +40,33 @@ void test() { SpBuf rhsSpBuf{sp}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.swap(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf(std::span{}); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.swap(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode `out` @@ -83,63 +74,49 @@ void test() { SpBuf rhsSpBuf{sp, std::ios_base::out}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.swap(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf rhsSpBuf{sp, std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); + assert(rhsSpBuf.span().size() == 4); - SpBuf spBuf; + SpBuf spBuf(std::span{}); assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.swap(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `ate` { SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf(std::span{}); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.swap(rhsSpBuf); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp index 6954538d89b7e..39b39f5a81764 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/swap_nonmember.pass.cpp @@ -37,41 +37,33 @@ void test() { SpBuf rhsSpBuf{sp}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); std::swap(spBuf, rhsSpBuf); assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf(std::span{}); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); std::swap(spBuf, rhsSpBuf); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode `out` @@ -79,63 +71,49 @@ void test() { SpBuf rhsSpBuf{sp, std::ios_base::out}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); std::swap(spBuf, rhsSpBuf); assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf rhsSpBuf{sp, std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); + assert(rhsSpBuf.span().size() == 4); - SpBuf spBuf; + SpBuf spBuf(std::span{}); assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); std::swap(spBuf, rhsSpBuf); assert(spBuf.span().data() == arr); - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `ate` { SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf(std::span{}); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); std::swap(spBuf, rhsSpBuf); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp index 797e0110fe441..ef8c8d0b44642 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/default.pass.cpp @@ -31,7 +31,6 @@ void test() { { SpBuf spBuf; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp index 370c79b92d7eb..4b45119e34014 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp @@ -51,7 +51,6 @@ void test() { { SpBuf spBuf{std::ios_base::in}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `out` @@ -59,22 +58,18 @@ void test() { SpBuf spBuf{std::ios_base::out}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf spBuf{std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf{std::ios_base::ate}; assert(spBuf.span().data() == nullptr); - // Mode `out` counts read character - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `ate` { SpBuf spBuf{std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } } @@ -85,6 +80,7 @@ int main(int, char**) { #endif test_sfinae(); test_sfinae>(); + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp index 874b9f1900c2f..f1eb1933e09c9 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp @@ -161,18 +161,15 @@ void test() { SpBuf rhsSpBuf; assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `in` @@ -180,17 +177,15 @@ void test() { SpBuf rhsSpBuf{std::ios_base::in}; assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `out` @@ -198,51 +193,38 @@ void test() { SpBuf rhsSpBuf{std::ios_base::out}; assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); - SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in | std::ios_base::binary}; - assert(rhsSpBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); - + SpBuf rhsSpBuf{std::ios_base::ate}; SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); + assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: `ate` + // Mode: multiple { - SpBuf rhsSpBuf{std::ios_base::ate}; + SpBuf rhsSpBuf{std::ios_base::out | std::ios_base::in | std::ios_base::ate}; SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == nullptr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } } @@ -257,35 +239,29 @@ void test() { SpBuf rhsSpBuf{sp}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } // Mode: `in` { SpBuf rhsSpBuf{sp, std::ios_base::in}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); } // Mode `out` @@ -293,54 +269,43 @@ void test() { SpBuf rhsSpBuf{sp, std::ios_base::out}; assert(rhsSpBuf.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::in | std::ios_base::binary}; + SpBuf rhsSpBuf{sp, std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); + assert(rhsSpBuf.span().size() == 4); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(rhsSpBuf.span().empty()); - assert(rhsSpBuf.span().size() == 0); + assert(rhsSpBuf.span().size() == 4); } // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base::ate}; + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); SpBuf spBuf{std::move(rhsSpBuf)}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); // Test after move assert(rhsSpBuf.span().data() == arr); - assert(!rhsSpBuf.span().empty()); assert(rhsSpBuf.span().size() == 4); } } @@ -356,6 +321,7 @@ int main(int, char**) { test_postconditions(); test_postconditions>(); #endif + #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp index cc88f7840427a..c33c741fd0707 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/span.mode.pass.cpp @@ -58,27 +58,23 @@ void test() { SpBuf spBuf{sp}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf{std::as_const(sp)}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `in` { SpBuf spBuf{sp, std::ios_base::in}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf{std::as_const(sp), std::ios_base::in}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `out` @@ -86,42 +82,23 @@ void test() { SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf{std::as_const(sp), std::ios_base::out}; assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - // Mode: multiple - { - SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); - } - { - SpBuf spBuf{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; - assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `ate` { SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } } @@ -136,27 +113,23 @@ void test() { SpBuf spBuf{sp}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf{std::as_const(sp)}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `in` { SpBuf spBuf{sp, std::ios_base::in}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } { SpBuf spBuf{std::as_const(sp), std::ios_base::in}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } // Mode `out` @@ -164,42 +137,34 @@ void test() { SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } { SpBuf spBuf{std::as_const(sp), std::ios_base::out}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf{sp, std::ios_base::ate}; assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); } { - SpBuf spBuf{std::as_const(sp), std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf{std::as_const(sp), std::ios_base::ate}; assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); } // Mode: `ate` { SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } { SpBuf spBuf{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp index 4dabf029a2509..df24aa877a4f5 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.pass.cpp @@ -33,7 +33,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) @@ -41,14 +40,12 @@ void test() { SpBuf spBuf(sp); assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `in` { SpBuf spBuf(sp, std::ios_base::in); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } // Mode: `out` @@ -56,22 +53,18 @@ void test() { SpBuf spBuf(sp, std::ios_base::out); assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf spBuf(sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf(sp, std::ios_base::ate); assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); } // Mode: `ate` { SpBuf spBuf(sp, std::ios_base::out | std::ios_base::ate); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp index b6721965e6f81..a2c61a4b5f068 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.members/span.span.pass.cpp @@ -34,59 +34,51 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) { SpBuf spBuf; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.span(arr); assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `in` { SpBuf spBuf{std::ios_base::in}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.span(arr); assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); } // Mode: `out` { SpBuf spBuf{std::ios_base::out}; assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.span(arr); assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary); + SpBuf spBuf(std::ios_base::ate); assert(spBuf.span().data() == nullptr); assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.span(arr); assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(!spBuf.span().empty()); + assert(spBuf.span().size() == 4); } // Mode: `ate` { diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp index e158cbb6503a6..fb6c6bbb6bdec 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.virtuals/setbuf.pass.cpp @@ -37,25 +37,21 @@ void test() { SpBuf spBuf{sp}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.pubsetbuf(nullptr, 0); assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `in` { SpBuf spBuf{sp, std::ios_base::in}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); spBuf.pubsetbuf(nullptr, 0); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode `out` @@ -63,39 +59,31 @@ void test() { SpBuf spBuf{sp, std::ios_base::out}; assert(spBuf.span().data() == arr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); spBuf.pubsetbuf(nullptr, 0); assert(spBuf.span().data() == nullptr); // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpBuf spBuf{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpBuf spBuf{sp, std::ios_base::ate}; assert(spBuf.span().data() == arr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); - assert(spBuf.span().size() == 0); + assert(spBuf.span().size() == 4); spBuf.pubsetbuf(nullptr, 0); assert(spBuf.span().data() == nullptr); - // Mode `out` counts read characters - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } // Mode: `ate` { SpBuf spBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(spBuf.span().data() == arr); - assert(!spBuf.span().empty()); assert(spBuf.span().size() == 4); spBuf.pubsetbuf(nullptr, 0); assert(spBuf.span().data() == nullptr); - assert(spBuf.span().empty()); assert(spBuf.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp index 60507b2ae7393..2fdb6869e22a0 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/assign.move.pass.cpp @@ -34,92 +34,76 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::in}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode: multiple + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt = std::move(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } } @@ -128,7 +112,6 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif - test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp index 74280970b999e..589b3af943026 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.move.pass.cpp @@ -34,92 +34,76 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } // Mode `out` { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); // Test after move assert(rhsSpSt.span().data() == arr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `ate` { SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } - // Mode: multiple + // Mode `ate` { - SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt{std::move(rhsSpSt)}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); // Test after move assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); } } @@ -128,7 +112,6 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif - test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp index 0b53aa926dade..b766266bc03bc 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.cons/ctor.span.mode.pass.cpp @@ -51,72 +51,61 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) { SpStream spSt{sp}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { SpStream spSt{std::as_const(sp)}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { SpStream spSt{std::as_const(sp), std::ios_base::in}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode `out` { SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } { SpStream spSt{std::as_const(sp), std::ios_base::out}; assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode `ate` { SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { SpStream spSt{std::as_const(sp), std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } - // Mode: multiple + // Mode `ate` { - SpStream spSt{sp, std::ios_base::ate | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } { - SpStream spSt{std::as_const(sp), std::ios_base::ate | std::ios_base::binary}; + SpStream spSt{std::as_const(sp), std::ios_base::out | std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } @@ -125,7 +114,6 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test_sfinae(); #endif - test_sfinae(); test_sfinae>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS @@ -136,7 +124,6 @@ int main(int, char**) { #ifndef TEST_HAS_NO_NASTY_STRING test(); #endif - test(); test>(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp index 1c2f4e76e727c..3e4ecb67224d4 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/rdbuf.pass.cpp @@ -33,7 +33,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) @@ -41,14 +40,12 @@ void test() { SpStream spSt{sp}; assert(spSt.rdbuf()->span().data() == arr); // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } // Mode: `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.rdbuf()->span().data() == arr); - assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); } // Mode: `out` @@ -56,22 +53,18 @@ void test() { SpStream spSt{sp, std::ios_base::out}; assert(spSt.rdbuf()->span().data() == arr); // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.rdbuf()->span().data() == arr); - // Mode `out` counts read characters - assert(spSt.rdbuf()->span().empty()); - assert(spSt.rdbuf()->span().size() == 0); + assert(spSt.rdbuf()->span().size() == 4); } // Mode: `ate` { SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; assert(spSt.rdbuf()->span().data() == arr); - assert(!spSt.rdbuf()->span().empty()); assert(spSt.rdbuf()->span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp index aa2f64dc1de1b..b23e411b99230 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.pass.cpp @@ -42,14 +42,12 @@ void test() { SpStream spSt{sp}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: `out` @@ -57,22 +55,18 @@ void test() { SpStream spSt{sp, std::ios_base::out}; assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream spSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{sp, std::ios_base::ate}; assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(spSt.span().size() == 4); } // Mode: `ate` { SpStream spSt{sp, std::ios_base::out | std::ios_base::ate}; assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp index bc997a84e2bc1..41477f3eaebf7 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.members/span.span.pass.cpp @@ -34,70 +34,58 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) { SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } // Mode: `in` { SpStream spSt{std::span{}, std::ios_base::in}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } // Mode: `out` { SpStream spSt{std::span{}, std::ios_base::out}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream spSt{std::span{}, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream spSt{std::span{}, std::ios_base::ate}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - // Mode `out` counts read characters - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(spSt.span().size() == 4); } // Mode: `ate` { SpStream spSt{std::span{}, std::ios_base::out | std::ios_base::ate}; assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.span(arr); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp index 6ec39470ae6e8..389023912d3cd 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap.pass.cpp @@ -33,7 +33,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) @@ -41,41 +40,32 @@ void test() { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); - assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `out` @@ -83,63 +73,49 @@ void test() { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(rhsSpSt.span().size() == 4); - SpStream spSt{std::span{}}; + SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `ate` { SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); spSt.swap(rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } } diff --git a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp index 79468d2364f51..0eeada5f3bc8c 100644 --- a/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanstream/spanstream.swap/swap_nonmember.pass.cpp @@ -29,7 +29,6 @@ void test() { std::span sp{arr}; assert(sp.data() == arr); - assert(!sp.empty()); assert(sp.size() == 4); // Mode: default (`in` | `out`) @@ -37,41 +36,33 @@ void test() { SpStream rhsSpSt{sp}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `in` { SpStream rhsSpSt{sp, std::ios_base::in}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode `out` @@ -79,50 +70,40 @@ void test() { SpStream rhsSpSt{sp, std::ios_base::out}; assert(rhsSpSt.span().data() == arr); // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); SpStream spSt{std::span{}}; assert(spSt.span().data() == nullptr); // Mode `out` counts read characters - assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); assert(spSt.span().size() == 0); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } - // Mode: multiple + // Mode: `ate` { - SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary}; + SpStream rhsSpSt{sp, std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - // Mode `out` counts read characters - assert(rhsSpSt.span().empty()); - assert(rhsSpSt.span().size() == 0); + assert(rhsSpSt.span().size() == 4); - SpStream spSt{std::span{}}; + SpStream spSt(std::span{}); assert(spSt.span().data() == nullptr); - // Mode `out` counts read characters assert(spSt.span().empty()); assert(spSt.span().size() == 0); std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(spSt.span().empty()); - assert(spSt.span().size() == 0); + assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } // Mode: `ate` { SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpSt.span().data() == arr); - assert(!rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 4); SpStream spSt(std::span{}); @@ -132,10 +113,8 @@ void test() { std::swap(spSt, rhsSpSt); assert(spSt.span().data() == arr); - assert(!spSt.span().empty()); assert(spSt.span().size() == 4); assert(rhsSpSt.span().data() == nullptr); - assert(rhsSpSt.span().empty()); assert(rhsSpSt.span().size() == 0); } } From 5023fa3a9fc9e30b4b32be470f51522a09c2b909 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Fri, 28 Mar 2025 11:36:36 +0200 Subject: [PATCH 104/120] Fix CI --- .../ispanstream/inherited.stream.ops.pass.cpp | 66 +++++++++---------- .../spanbuf.assign/assign.move.pass.cpp | 2 +- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp index 331764c641a4c..1158d3e4430b9 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp @@ -28,9 +28,6 @@ #include "../helper_macros.h" #include "../helper_types.h" -#include // REMOVE ME -#include // REMOVE ME - template void test_ispanstream(std::basic_ispanstream& spSt, std::size_t size) { assert(spSt); @@ -80,42 +77,41 @@ void test() { constexpr std::basic_string_view sv{SV("zmt 94 hkt 82 pir 43vr")}; assert(sv.size() < 30UZ); - // Create a std::span test value - CharT arr[30UZ]{}; - initialize_array_from_string_view(arr, sv); - - std::span sp{arr}; - - // Create a "Read Only Sequence" test value - CharT rosArr[30UZ]{}; - initialize_array_from_string_view(rosArr, sv); - - ReadOnlySpan ros{rosArr}; - assert(ros.size() == 30UZ); - - // std::span` + Mode: default (`in`) - { - SpStream spSt(sp); - test_ispanstream(spSt, 30UZ); - } - // std::span` + Mode: explicit `in` - { - SpStream spSt(sp, std::ios_base::in); - test_ispanstream(spSt, 30UZ); - } - - // `ReadOnlySpan` + Mode: default (`in`) { - SpStream spSt(ros); - test_ispanstream(spSt, 30UZ); + // Create a std::span test value + CharT arr[30UZ]{}; + initialize_array_from_string_view(arr, sv); + + std::span sp{arr}; + + // std::span` + Mode: default (`in`) + { + SpStream spSt(sp); + test_ispanstream(spSt, 30UZ); + } + // std::span` + Mode: explicit `in` + { + SpStream spSt(sp, std::ios_base::in); + test_ispanstream(spSt, 30UZ); + } } { - SpStream spSt(sp, std::ios_base::ate); - std::println(stderr, "spSt.span().size() = {}", spSt.span().size()); - // std::println(stderr, "spSt.tellg() = {}", spSt.tellg()); - std::cerr << "spSt.tellg() = " << spSt.tellg() << std::endl; - assert(false); + // Create a "Read Only Sequence" test value + CharT arr[30UZ]{}; + initialize_array_from_string_view(arr, sv); + + ReadOnlySpan ros{arr}; + assert(ros.size() == 30UZ); + + { + SpStream spSt(ros); + test_ispanstream(spSt, 30UZ); + } + { + SpStream spSt(std::move(ros)); + test_ispanstream(spSt, 30UZ); + } } } diff --git a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp index 5724ba89043ee..b0d6cf68b01dd 100644 --- a/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.assign/assign.move.pass.cpp @@ -291,7 +291,7 @@ void test() { } // Mode: `ate` { - SpBuf rhsSpBuf{sp, std::ios_base : out | std::ios_base::ate}; + SpBuf rhsSpBuf{sp, std::ios_base::out | std::ios_base::ate}; assert(rhsSpBuf.span().data() == arr); assert(rhsSpBuf.span().size() == 4); From df9eaeceb7889f7d8b369c5a49f9496d169e9d3f Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 1 Apr 2025 19:26:31 +0300 Subject: [PATCH 105/120] WIP: Test spanbuf pointers in streams --- .../input.output/span.streams/helper_types.h | 14 ++++++++++++ .../ispanstream.members/rdbuf.pass.cpp | 22 +++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/libcxx/test/std/input.output/span.streams/helper_types.h b/libcxx/test/std/input.output/span.streams/helper_types.h index 0d7f99c7e653b..0196cca8399d4 100644 --- a/libcxx/test/std/input.output/span.streams/helper_types.h +++ b/libcxx/test/std/input.output/span.streams/helper_types.h @@ -128,4 +128,18 @@ static_assert(!std::convertible_to, std::span +class spanbuf_wrapper : public std::basic_spanbuf { +public: + using std::basic_spanbuf::eback; + using std::basic_spanbuf::egptr; + using std::basic_spanbuf::epptr; + using std::basic_spanbuf::gptr; + using std::basic_spanbuf::pbase; + using std::basic_spanbuf::pptr; +}; + + #endif // TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H diff --git a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp index 1560399c37905..c43b1370fd9bf 100644 --- a/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp +++ b/libcxx/test/std/input.output/span.streams/ispanstream/ispanstream.members/rdbuf.pass.cpp @@ -25,9 +25,11 @@ #include "nasty_string.h" #include "test_macros.h" +#include "../../helper_types.h" + template > void test() { - using SpStream = std::basic_ospanstream; + using SpStream = std::basic_ispanstream; CharT arr[4]; @@ -38,19 +40,21 @@ void test() { // Mode: default (`in`) { SpStream spSt{sp}; - assert(spSt.rdbuf()->span().data() == arr); - assert(spSt.rdbuf()->span().size() == 0); + auto* spBuf = static_cast*>(spSt.rdbuf()); + + assert(spBuf->span().size() == 4); + assert(spBuf->span().data() == arr); + assert(spBuf->eback() == arr); + assert(spBuf->gptr() == arr); + assert(spBuf->egptr() == arr + 4); + assert(spBuf->pbase() == nullptr); + assert(spBuf->pptr() == nullptr); + assert(spBuf->epptr() == nullptr); } // Mode: explicit `in` { SpStream spSt{sp, std::ios_base::in}; assert(spSt.rdbuf()->span().data() == arr); - assert(spSt.rdbuf()->span().size() == 0); - } - // Mode: `ate` - { - SpStream spSt{sp, std::ios_base::ate}; - assert(spSt.rdbuf()->span().data() == arr); assert(spSt.rdbuf()->span().size() == 4); } } From 22d085c634696b0cc40d65083d5911b019d04575 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 00:10:19 +0300 Subject: [PATCH 106/120] Removed `_LIBCPP_TEMPLATE_VIS` as of https://github.com/llvm/llvm-project/pull/134885 and https://github.com/llvm/llvm-project/pull/133233 --- libcxx/include/__fwd/spanstream.h | 8 ++++---- libcxx/include/spanstream | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libcxx/include/__fwd/spanstream.h b/libcxx/include/__fwd/spanstream.h index 9e52ac9f3472e..655a5af22fc27 100644 --- a/libcxx/include/__fwd/spanstream.h +++ b/libcxx/include/__fwd/spanstream.h @@ -21,13 +21,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 23 template > -class _LIBCPP_TEMPLATE_VIS basic_spanbuf; +class basic_spanbuf; template > -class _LIBCPP_TEMPLATE_VIS basic_ispanstream; +class basic_ispanstream; template > -class _LIBCPP_TEMPLATE_VIS basic_ospanstream; +class basic_ospanstream; template > -class _LIBCPP_TEMPLATE_VIS basic_spanstream; +class basic_spanstream; using spanbuf = basic_spanbuf; using ispanstream = basic_ispanstream; diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index 62d00dabc6848..bea7b801d879d 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -90,7 +90,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // Class template basic_spanbuf [spanbuf] template -class _LIBCPP_TEMPLATE_VIS basic_spanbuf : public basic_streambuf<_CharT, _Traits> { +class basic_spanbuf : public basic_streambuf<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; @@ -254,7 +254,7 @@ using std::wspanbuf; // Class template basic_ispanstream [ispanstream] template -class _LIBCPP_TEMPLATE_VIS basic_ispanstream : public basic_istream<_CharT, _Traits> { +class basic_ispanstream : public basic_istream<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; @@ -332,7 +332,7 @@ using std::wispanstream; // Class template basic_ospanstream [ospanstream] template -class _LIBCPP_TEMPLATE_VIS basic_ospanstream : public basic_ostream<_CharT, _Traits> { +class basic_ospanstream : public basic_ostream<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; @@ -393,7 +393,7 @@ using std::wospanstream; # endif template -class _LIBCPP_TEMPLATE_VIS basic_spanstream : public basic_iostream<_CharT, _Traits> { +class basic_spanstream : public basic_iostream<_CharT, _Traits> { public: using char_type = _CharT; using int_type = typename _Traits::int_type; From 40e2661a7b6467ea74a4ca191197a11629735b55 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 00:17:26 +0300 Subject: [PATCH 107/120] Re-run generator scripts --- .../spanstream.version.compile.pass.cpp | 58 +++++++++---------- .../version.version.compile.pass.cpp | 32 ++++------ 2 files changed, 38 insertions(+), 52 deletions(-) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index 53c528e320a87..4989009e60234 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -5,11 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// + // WARNING: This test was generated by generate_feature_test_macro_components.py // and should not be edited manually. -// -// clang-format off // UNSUPPORTED: no-localization @@ -17,54 +15,54 @@ // Test the feature test macros defined by -/* Constant Value - __cpp_lib_spanstream 202106L [C++23] -*/ +// clang-format off #include #include "test_macros.h" #if TEST_STD_VER < 14 -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif #elif TEST_STD_VER == 14 -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif #elif TEST_STD_VER == 17 -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif #elif TEST_STD_VER == 20 -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif #elif TEST_STD_VER == 23 -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++23" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++23" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" +# endif #elif TEST_STD_VER > 23 -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++26" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++26" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" +# endif #endif // TEST_STD_VER > 23 +// clang-format on + diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index 962688e06188a..49c9f7df71602 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -5913,17 +5913,11 @@ # error "__cpp_lib_span_initializer_list should not be defined before c++26" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++23" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++23" -# endif -# else -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" # endif # ifndef __cpp_lib_ssize @@ -7879,17 +7873,11 @@ # error "__cpp_lib_span_initializer_list should have the value 202311L in c++26" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++26" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++26" -# endif -# else -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" # endif # ifndef __cpp_lib_ssize From 628db92264fe72593e4b00f13c2ca58c6bb74328 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 00:21:03 +0300 Subject: [PATCH 108/120] Fixed format --- libcxx/test/std/input.output/span.streams/helper_types.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/test/std/input.output/span.streams/helper_types.h b/libcxx/test/std/input.output/span.streams/helper_types.h index 0196cca8399d4..a4eb47cc09fd3 100644 --- a/libcxx/test/std/input.output/span.streams/helper_types.h +++ b/libcxx/test/std/input.output/span.streams/helper_types.h @@ -141,5 +141,4 @@ class spanbuf_wrapper : public std::basic_spanbuf { using std::basic_spanbuf::pptr; }; - #endif // TEST_STD_INPUTOUTPUT_SPANSTREAMS_TYPES_H From 0ca74dde824640451ed7c6fba6f93090c72db5be Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 00:29:31 +0300 Subject: [PATCH 109/120] Fixed formatting --- .../support.limits.general/spanstream.version.compile.pass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index 4989009e60234..8ab394d8168ac 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -65,4 +65,3 @@ #endif // TEST_STD_VER > 23 // clang-format on - From a0fcde37c68dcb68971fadb0ebc48adba7aaae01 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 00:50:13 +0300 Subject: [PATCH 110/120] Fixed formatting again --- .../support.limits.general/spanstream.version.compile.pass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index 8ab394d8168ac..4989009e60234 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -65,3 +65,4 @@ #endif // TEST_STD_VER > 23 // clang-format on + From 0090ce1911759c6d96f7eef81e46627ffe9bb27d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 01:06:55 +0300 Subject: [PATCH 111/120] Run generator scripts --- libcxx/docs/FeatureTestMacroTable.rst | 2 +- libcxx/include/version | 2 +- libcxx/modules/std.compat.cppm.in | 3 + libcxx/modules/std.cppm.in | 3 + .../spanstream.version.compile.pass.cpp | 68 ------------------- .../version.version.compile.pass.cpp | 32 ++++++--- .../generate_feature_test_macro_components.py | 1 + libcxx/utils/libcxx/header_information.py | 1 + 8 files changed, 32 insertions(+), 80 deletions(-) delete mode 100644 libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index 5f8151d241b49..61805726a4ff0 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -394,7 +394,7 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_reference_from_temporary`` *unimplemented* ---------------------------------------------------------- ----------------- - ``__cpp_lib_spanstream`` ``202106L`` + ``__cpp_lib_spanstream`` *unimplemented* ---------------------------------------------------------- ----------------- ``__cpp_lib_stacktrace`` *unimplemented* ---------------------------------------------------------- ----------------- diff --git a/libcxx/include/version b/libcxx/include/version index a83f7b36958c5..d98049bd57046 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -530,7 +530,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_ranges_to_container 202202L // # define __cpp_lib_ranges_zip 202110L // # define __cpp_lib_reference_from_temporary 202202L -# define __cpp_lib_spanstream 202106L +// # define __cpp_lib_spanstream 202106L // # define __cpp_lib_stacktrace 202011L # define __cpp_lib_stdatomic_h 202011L # define __cpp_lib_string_contains 202011L diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in index b4222ba307c2d..dd7385bf33a42 100644 --- a/libcxx/modules/std.compat.cppm.in +++ b/libcxx/modules/std.compat.cppm.in @@ -66,6 +66,9 @@ module; # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() +# if __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +# endif // __has_include() # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index 4338361072af6..8cbed89ec517b 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -153,6 +153,9 @@ module; # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() +# if __has_include() +# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" +# endif // __has_include() # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp deleted file mode 100644 index 4989009e60234..0000000000000 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// WARNING: This test was generated by generate_feature_test_macro_components.py -// and should not be edited manually. - -// UNSUPPORTED: no-localization - -// - -// Test the feature test macros defined by - -// clang-format off - -#include -#include "test_macros.h" - -#if TEST_STD_VER < 14 - -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif - -#elif TEST_STD_VER == 14 - -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif - -#elif TEST_STD_VER == 17 - -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif - -#elif TEST_STD_VER == 20 - -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined before c++23" -# endif - -#elif TEST_STD_VER == 23 - -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++23" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++23" -# endif - -#elif TEST_STD_VER > 23 - -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++26" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++26" -# endif - -#endif // TEST_STD_VER > 23 - -// clang-format on - diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index 49c9f7df71602..962688e06188a 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -5913,11 +5913,17 @@ # error "__cpp_lib_span_initializer_list should not be defined before c++26" # endif -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++23" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++23" +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" +# endif +# else +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" +# endif # endif # ifndef __cpp_lib_ssize @@ -7873,11 +7879,17 @@ # error "__cpp_lib_span_initializer_list should have the value 202311L in c++26" # endif -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++26" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++26" +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" +# endif +# else +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" +# endif # endif # ifndef __cpp_lib_ssize diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index bf9508e36410a..5b7497d8dcc2e 100644 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -1297,6 +1297,7 @@ def add_version_header(tc): "name": "__cpp_lib_spanstream", "values": {"c++23": 202106}, "headers": ["spanstream"], + "unimplemented": True, }, { "name": "__cpp_lib_ssize", diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py index e6a8fd53a1e0a..d06271a7908cc 100644 --- a/libcxx/utils/libcxx/header_information.py +++ b/libcxx/utils/libcxx/header_information.py @@ -169,6 +169,7 @@ def __hash__(self) -> int: "inplace_vector", "linalg", "rcu", + "spanstream", "stacktrace", "stdfloat", "text_encoding", From eda6e7f3fd32551b3da073cfd381dff8c7f7d575 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 01:14:16 +0300 Subject: [PATCH 112/120] Try again --- .../spanstream.version.compile.pass.cpp | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp new file mode 100644 index 0000000000000..e54e785627f18 --- /dev/null +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// WARNING: This test was generated by generate_feature_test_macro_components.py +// and should not be edited manually. + +// UNSUPPORTED: no-localization + +// + +// Test the feature test macros defined by + +// clang-format off + +#include +#include "test_macros.h" + +#if TEST_STD_VER < 14 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 14 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 17 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 20 + +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined before c++23" +# endif + +#elif TEST_STD_VER == 23 + +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" +# endif +# else +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" +# endif +# endif + +#elif TEST_STD_VER > 23 + +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" +# endif +# else +# ifdef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" +# endif +# endif + +#endif // TEST_STD_VER > 23 + +// clang-format on + From 066872d4f6990f18ec711eb939398c4f010298cf Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 01:16:07 +0300 Subject: [PATCH 113/120] Try again --- libcxx/modules/std.compat.cppm.in | 3 --- libcxx/modules/std.cppm.in | 3 --- libcxx/utils/libcxx/header_information.py | 1 - 3 files changed, 7 deletions(-) diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in index dd7385bf33a42..b4222ba307c2d 100644 --- a/libcxx/modules/std.compat.cppm.in +++ b/libcxx/modules/std.compat.cppm.in @@ -66,9 +66,6 @@ module; # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() -# if __has_include() -# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" -# endif // __has_include() # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index 8cbed89ec517b..4338361072af6 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -153,9 +153,6 @@ module; # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() -# if __has_include() -# error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" -# endif // __has_include() # if __has_include() # error "please update the header information for in headers_not_available in utils/libcxx/header_information.py" # endif // __has_include() diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py index d06271a7908cc..e6a8fd53a1e0a 100644 --- a/libcxx/utils/libcxx/header_information.py +++ b/libcxx/utils/libcxx/header_information.py @@ -169,7 +169,6 @@ def __hash__(self) -> int: "inplace_vector", "linalg", "rcu", - "spanstream", "stacktrace", "stdfloat", "text_encoding", From 645f94fb91dd338b28ce00b305c8882e5e83ca8d Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 01:17:31 +0300 Subject: [PATCH 114/120] Try again --- libcxx/docs/FeatureTestMacroTable.rst | 2 +- libcxx/include/version | 2 +- .../spanstream.version.compile.pass.cpp | 32 ++++++------------- .../version.version.compile.pass.cpp | 32 ++++++------------- .../generate_feature_test_macro_components.py | 1 - 5 files changed, 22 insertions(+), 47 deletions(-) diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index 61805726a4ff0..5f8151d241b49 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -394,7 +394,7 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_reference_from_temporary`` *unimplemented* ---------------------------------------------------------- ----------------- - ``__cpp_lib_spanstream`` *unimplemented* + ``__cpp_lib_spanstream`` ``202106L`` ---------------------------------------------------------- ----------------- ``__cpp_lib_stacktrace`` *unimplemented* ---------------------------------------------------------- ----------------- diff --git a/libcxx/include/version b/libcxx/include/version index d98049bd57046..a83f7b36958c5 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -530,7 +530,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_ranges_to_container 202202L // # define __cpp_lib_ranges_zip 202110L // # define __cpp_lib_reference_from_temporary 202202L -// # define __cpp_lib_spanstream 202106L +# define __cpp_lib_spanstream 202106L // # define __cpp_lib_stacktrace 202011L # define __cpp_lib_stdatomic_h 202011L # define __cpp_lib_string_contains 202011L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index e54e785627f18..4989009e60234 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -46,32 +46,20 @@ #elif TEST_STD_VER == 23 -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++23" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++23" -# endif -# else -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" # endif #elif TEST_STD_VER > 23 -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++26" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++26" -# endif -# else -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" # endif #endif // TEST_STD_VER > 23 diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index 962688e06188a..49c9f7df71602 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -5913,17 +5913,11 @@ # error "__cpp_lib_span_initializer_list should not be defined before c++26" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++23" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++23" -# endif -# else -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++23" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++23" # endif # ifndef __cpp_lib_ssize @@ -7879,17 +7873,11 @@ # error "__cpp_lib_span_initializer_list should have the value 202311L in c++26" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should be defined in c++26" -# endif -# if __cpp_lib_spanstream != 202106L -# error "__cpp_lib_spanstream should have the value 202106L in c++26" -# endif -# else -# ifdef __cpp_lib_spanstream -# error "__cpp_lib_spanstream should not be defined because it is unimplemented in libc++!" -# endif +# ifndef __cpp_lib_spanstream +# error "__cpp_lib_spanstream should be defined in c++26" +# endif +# if __cpp_lib_spanstream != 202106L +# error "__cpp_lib_spanstream should have the value 202106L in c++26" # endif # ifndef __cpp_lib_ssize diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 5b7497d8dcc2e..bf9508e36410a 100644 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -1297,7 +1297,6 @@ def add_version_header(tc): "name": "__cpp_lib_spanstream", "values": {"c++23": 202106}, "headers": ["spanstream"], - "unimplemented": True, }, { "name": "__cpp_lib_ssize", From 5b7abb337d831387c6602486e72f5929dcca66d0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 01:24:42 +0300 Subject: [PATCH 115/120] Update libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp --- .../support.limits.general/spanstream.version.compile.pass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index 4989009e60234..b2da6f0fae890 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -66,3 +66,4 @@ // clang-format on + From b94890c4cb8f1508596141b833486b066861b8f1 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sat, 17 May 2025 01:28:07 +0300 Subject: [PATCH 116/120] Update libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp --- .../support.limits.general/spanstream.version.compile.pass.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index b2da6f0fae890..4989009e60234 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -66,4 +66,3 @@ // clang-format on - From 5e314c3b9471499f76c2cd9b0581cb8603dbfa20 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Sun, 18 May 2025 20:53:08 +0300 Subject: [PATCH 117/120] Fix CI - `addressof` --- libcxx/include/spanstream | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/include/spanstream b/libcxx/include/spanstream index bea7b801d879d..c61db77d66f45 100644 --- a/libcxx/include/spanstream +++ b/libcxx/include/spanstream @@ -209,7 +209,7 @@ protected: off_type __newoff; - if (__builtin_add_overflow(__baseoff, __off, &__newoff) || (__newoff < off_type{0}) || + if (__builtin_add_overflow(__baseoff, __off, std::addressof(__newoff)) || (__newoff < off_type{0}) || std::cmp_greater(__newoff, __buf_.size())) return __error; From 73088da098e8ba2025ebab735181578410c00dbd Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 22 Jul 2025 20:24:35 +0300 Subject: [PATCH 118/120] Update libcxx/docs/Status/Cxx23Papers.csv --- libcxx/docs/Status/Cxx23Papers.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv index b260d6a72fff9..ab58bd725d9e9 100644 --- a/libcxx/docs/Status/Cxx23Papers.csv +++ b/libcxx/docs/Status/Cxx23Papers.csv @@ -12,7 +12,7 @@ "`P2259R1 `__","Repairing input range adaptors and counted_iterator","2021-02 (Virtual)","","","" "","","","","","" "`P0401R6 `__","Providing size feedback in the Allocator interface","2021-06 (Virtual)","|Complete|","15","" -"`P0448R4 `__","A ``strstream`` replacement using ``span`` as buffer","2021-06 (Virtual)","|Complete|","21" +"`P0448R4 `__","A ``strstream`` replacement using ``span`` as buffer","2021-06 (Virtual)","|Complete|","22" "`P1132R8 `__","out_ptr - a scalable output pointer abstraction","2021-06 (Virtual)","|Complete|","19","" "`P1328R1 `__","Making std::type_info::operator== constexpr","2021-06 (Virtual)","|Complete|","17","" "`P1425R4 `__","Iterators pair constructors for stack and queue","2021-06 (Virtual)","|Complete|","14","" From 5b78b4dfca97323fbbb6a93c82567d1c451c712e Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 22 Jul 2025 21:50:41 +0300 Subject: [PATCH 119/120] LLVM22 --- libcxx/docs/ReleaseNotes/21.rst | 1 - libcxx/docs/ReleaseNotes/22.rst | 1 + libcxx/modules/std.cppm.in | 6 ++---- .../spanstream.version.compile.pass.cpp | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst index cd9883e1c8785..d31ca0130cb80 100644 --- a/libcxx/docs/ReleaseNotes/21.rst +++ b/libcxx/docs/ReleaseNotes/21.rst @@ -43,7 +43,6 @@ Implemented Papers - P1361R2: Integration of chrono with text formatting (`Github `__) - P2255R2: A type trait to detect reference binding to temporary (implemented the type traits only) (`Github `__) - P2372R3: Fixing locale handling in chrono formatters (`Github `__) -- P0448R4: A ``strstream`` replacement using ``span`` as buffer (`Github `__) - P2562R1: ``constexpr`` Stable Sorting (`Github `__) - P0472R3: Put std::monostate in (`Github `__) - P1222R4: A Standard ``flat_set`` (`Github `__) diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst index 15bf46d44b07f..cdf54b14e6b9d 100644 --- a/libcxx/docs/ReleaseNotes/22.rst +++ b/libcxx/docs/ReleaseNotes/22.rst @@ -39,6 +39,7 @@ Implemented Papers ------------------ - P2321R2: ``zip`` (`Github `__) (The paper is partially implemented. ``zip_transform_view`` is implemented in this release) +- P0448R4: A ``strstream`` replacement using ``span`` as buffer (`Github `__) Improvements and New Features ----------------------------- diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index 4338361072af6..c25397ab64f52 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -100,10 +100,8 @@ module; #include #include #include -# include -#endif -#if _LIBCPP_HAS_LOCALIZATION -# include +#include +#include #include #include #include diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp index 4989009e60234..8ab394d8168ac 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/spanstream.version.compile.pass.cpp @@ -65,4 +65,3 @@ #endif // TEST_STD_VER > 23 // clang-format on - From a8ada49bbb7723e6fb168166aaed8b91ef36a0ab Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 22 Jul 2025 22:41:58 +0300 Subject: [PATCH 120/120] Transitive includes --- libcxx/test/libcxx/transitive_includes/cxx03.csv | 5 +++++ libcxx/test/libcxx/transitive_includes/cxx11.csv | 5 +++++ libcxx/test/libcxx/transitive_includes/cxx14.csv | 5 +++++ libcxx/test/libcxx/transitive_includes/cxx17.csv | 5 +++++ libcxx/test/libcxx/transitive_includes/cxx26.csv | 1 - 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index 52907ade550a1..10d713a53a376 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -122,15 +122,19 @@ atomic ratio atomic type_traits atomic version barrier atomic +barrier cctype barrier climits barrier cmath barrier compare barrier concepts barrier cstddef barrier cstdint +barrier cstdio barrier cstdlib barrier cstring barrier ctime +barrier cwchar +barrier cwctype barrier exception barrier initializer_list barrier iosfwd @@ -2088,6 +2092,7 @@ stdexcept new stdexcept type_traits stdexcept typeinfo stdexcept version +stop_token cstddef stop_token iosfwd stop_token version streambuf algorithm diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 52907ade550a1..10d713a53a376 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -122,15 +122,19 @@ atomic ratio atomic type_traits atomic version barrier atomic +barrier cctype barrier climits barrier cmath barrier compare barrier concepts barrier cstddef barrier cstdint +barrier cstdio barrier cstdlib barrier cstring barrier ctime +barrier cwchar +barrier cwctype barrier exception barrier initializer_list barrier iosfwd @@ -2088,6 +2092,7 @@ stdexcept new stdexcept type_traits stdexcept typeinfo stdexcept version +stop_token cstddef stop_token iosfwd stop_token version streambuf algorithm diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 24aba8774f082..d93fbe1d82980 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -125,15 +125,19 @@ atomic ratio atomic type_traits atomic version barrier atomic +barrier cctype barrier climits barrier cmath barrier compare barrier concepts barrier cstddef barrier cstdint +barrier cstdio barrier cstdlib barrier cstring barrier ctime +barrier cwchar +barrier cwctype barrier exception barrier initializer_list barrier iosfwd @@ -2129,6 +2133,7 @@ stdexcept new stdexcept type_traits stdexcept typeinfo stdexcept version +stop_token cstddef stop_token iosfwd stop_token version streambuf algorithm diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index 16c0235061eff..439650d690378 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -122,15 +122,19 @@ atomic ratio atomic type_traits atomic version barrier atomic +barrier cctype barrier climits barrier cmath barrier compare barrier concepts barrier cstddef barrier cstdint +barrier cstdio barrier cstdlib barrier cstring barrier ctime +barrier cwchar +barrier cwctype barrier exception barrier initializer_list barrier iosfwd @@ -2141,6 +2145,7 @@ stdexcept new stdexcept type_traits stdexcept typeinfo stdexcept version +stop_token cstddef stop_token iosfwd stop_token version streambuf algorithm diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 40979359dde0b..c5a010511f44e 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -895,7 +895,6 @@ spanstream iosfwd spanstream iostream spanstream istream spanstream limits -spanstream locale spanstream optional spanstream ostream spanstream print