Author: marshall Date: Thu Apr 26 09:16:45 2018 New Revision: 330955 URL: http://llvm.org/viewvc/llvm-project?rev=330955&view=rev Log: Move old test into test/libcxx, and implement new version of test for ostreambuf_iterator::failed. Fixes PR#37245. Thanks to Billy O'Neill for the bug report.
Added: libcxx/trunk/test/libcxx/iterators/failed.pass.cpp - copied, changed from r330716, libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp Modified: libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp Copied: libcxx/trunk/test/libcxx/iterators/failed.pass.cpp (from r330716, libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp) URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/iterators/failed.pass.cpp?p2=libcxx/trunk/test/libcxx/iterators/failed.pass.cpp&p1=libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp&r1=330716&r2=330955&rev=330955&view=diff ============================================================================== --- libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp (original) +++ libcxx/trunk/test/libcxx/iterators/failed.pass.cpp Thu Apr 26 09:16:45 2018 @@ -12,6 +12,8 @@ // class ostreambuf_iterator // bool failed() const throw(); +// +// Extension: constructing from NULL is UB; we just make it a failed iterator #include <iterator> #include <sstream> Modified: libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp?rev=330955&r1=330954&r2=330955&view=diff ============================================================================== --- libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp (original) +++ libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp Thu Apr 26 09:16:45 2018 @@ -17,14 +17,27 @@ #include <sstream> #include <cassert> +template <typename Char, typename Traits = std::char_traits<Char> > +struct my_streambuf : public std::basic_streambuf<Char,Traits> { + typedef typename std::basic_streambuf<Char,Traits>::int_type int_type; + typedef typename std::basic_streambuf<Char,Traits>::char_type char_type; + + my_streambuf() {} + int_type sputc(char_type) { return Traits::eof(); } + }; + int main() { { - std::ostreambuf_iterator<char> i(nullptr); + my_streambuf<char> buf; + std::ostreambuf_iterator<char> i(&buf); + i = 'a'; assert(i.failed()); } { - std::ostreambuf_iterator<wchar_t> i(nullptr); + my_streambuf<wchar_t> buf; + std::ostreambuf_iterator<wchar_t> i(&buf); + i = L'a'; assert(i.failed()); } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits