diff options
| author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
| commit | 5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch) | |
| tree | afde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator | |
| parent | f11e8eab527fba316c64112f6e05de1a79693a3e (diff) | |
| download | bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip | |
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator')
7 files changed, 250 insertions, 0 deletions
diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp new file mode 100644 index 00000000000..c46cf482229 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// class ostreambuf_iterator + +// ostreambuf_iterator(ostream_type& s) throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator<char> i(outf); + assert(!i.failed()); + } + { + std::wostringstream outf; + std::ostreambuf_iterator<wchar_t> i(outf); + assert(!i.failed()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp new file mode 100644 index 00000000000..1576b7d481a --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// class ostreambuf_iterator + +// ostreambuf_iterator(streambuf_type* s) throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator<char> i(outf.rdbuf()); + assert(!i.failed()); + } + { + std::wostringstream outf; + std::ostreambuf_iterator<wchar_t> i(outf.rdbuf()); + assert(!i.failed()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp new file mode 100644 index 00000000000..91d7b692791 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// class ostreambuf_iterator + +// ostreambuf_iterator<charT,traits>& +// operator=(charT c); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator<char> i(outf); + i = 'a'; + assert(outf.str() == "a"); + i = 'b'; + assert(outf.str() == "ab"); + } + { + std::wostringstream outf; + std::ostreambuf_iterator<wchar_t> i(outf); + i = L'a'; + assert(outf.str() == L"a"); + i = L'b'; + assert(outf.str() == L"ab"); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp new file mode 100644 index 00000000000..d0861641025 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// class ostreambuf_iterator + +// ostreambuf_iterator<charT,traits>& operator*(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator<char> i(outf); + std::ostreambuf_iterator<char>& iref = *i; + assert(&iref == &i); + } + { + std::wostringstream outf; + std::ostreambuf_iterator<wchar_t> i(outf); + std::ostreambuf_iterator<wchar_t>& iref = *i; + assert(&iref == &i); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp new file mode 100644 index 00000000000..9d93bad370d --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// class ostreambuf_iterator + +// bool failed() const throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostreambuf_iterator<char> i(nullptr); + assert(i.failed()); + } + { + std::ostreambuf_iterator<wchar_t> i(nullptr); + assert(i.failed()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp new file mode 100644 index 00000000000..7461ce16347 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// class ostreambuf_iterator + +// ostreambuf_iterator<charT,traits>& operator++(); +// ostreambuf_iterator<charT,traits>& operator++(int); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostreambuf_iterator<char> i(outf); + std::ostreambuf_iterator<char>& iref = ++i; + assert(&iref == &i); + std::ostreambuf_iterator<char>& iref2 = i++; + assert(&iref2 == &i); + } + { + std::wostringstream outf; + std::ostreambuf_iterator<wchar_t> i(outf); + std::ostreambuf_iterator<wchar_t>& iref = ++i; + assert(&iref == &i); + std::ostreambuf_iterator<wchar_t>& iref2 = i++; + assert(&iref2 == &i); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp new file mode 100644 index 00000000000..a699b241983 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <iterator> + +// template <class charT, class traits = char_traits<charT> > +// class ostreambuf_iterator +// : public iterator<output_iterator_tag, void, void, void, void> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef basic_streambuf<charT, traits> streambuf_type; +// typedef basic_ostream<charT, traits> ostream_type; +// ... + +#include <iterator> +#include <string> +#include <type_traits> + +int main() +{ + typedef std::ostreambuf_iterator<char> I1; + static_assert((std::is_convertible<I1, + std::iterator<std::output_iterator_tag, void, void, void, void> >::value), ""); + static_assert((std::is_same<I1::char_type, char>::value), ""); + static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), ""); + static_assert((std::is_same<I1::ostream_type, std::ostream>::value), ""); + + typedef std::ostreambuf_iterator<wchar_t> I2; + static_assert((std::is_convertible<I2, + std::iterator<std::output_iterator_tag, void, void, void, void> >::value), ""); + static_assert((std::is_same<I2::char_type, wchar_t>::value), ""); + static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), ""); + static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), ""); + static_assert((std::is_same<I2::ostream_type, std::wostream>::value), ""); +} |

