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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@330955 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2018-04-26 16:16:45 +00:00
parent db0ba4480a
commit a5996e8dc9
2 changed files with 47 additions and 2 deletions

View File

@@ -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());
}
}