diff --git a/test/libcxx/iterators/failed.pass.cpp b/test/libcxx/iterators/failed.pass.cpp new file mode 100644 index 000000000..2e4717b38 --- /dev/null +++ b/test/libcxx/iterators/failed.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// class ostreambuf_iterator + +// bool failed() const throw(); +// +// Extension: constructing from NULL is UB; we just make it a failed iterator + +#include +#include +#include + +int main() +{ + { + std::ostreambuf_iterator i(nullptr); + assert(i.failed()); + } + { + std::ostreambuf_iterator i(nullptr); + assert(i.failed()); + } +} diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp index 9d93bad37..5cc9cf928 100644 --- a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp +++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp @@ -17,14 +17,27 @@ #include #include +template > +struct my_streambuf : public std::basic_streambuf { + typedef typename std::basic_streambuf::int_type int_type; + typedef typename std::basic_streambuf::char_type char_type; + + my_streambuf() {} + int_type sputc(char_type) { return Traits::eof(); } + }; + int main() { { - std::ostreambuf_iterator i(nullptr); + my_streambuf buf; + std::ostreambuf_iterator i(&buf); + i = 'a'; assert(i.failed()); } { - std::ostreambuf_iterator i(nullptr); + my_streambuf buf; + std::ostreambuf_iterator i(&buf); + i = L'a'; assert(i.failed()); } }