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 | |
| 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')
43 files changed, 1579 insertions, 0 deletions
diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp new file mode 100644 index 00000000000..0d70c7fc9ed --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 istream_iterator + +// istream_iterator(const istream_iterator& x); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istream_iterator<int> io; + std::istream_iterator<int> i = io; + assert(i == std::istream_iterator<int>()); + } + { + std::istringstream inf(" 1 23"); + std::istream_iterator<int> io(inf); + std::istream_iterator<int> i = io; + assert(i != std::istream_iterator<int>()); + int j = 0; + j = *i; + assert(j == 1); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp new file mode 100644 index 00000000000..f6c3dba7ae6 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 istream_iterator + +// istream_iterator(); + +#include <iterator> +#include <cassert> + +int main() +{ + std::istream_iterator<int> i; + assert(i == std::istream_iterator<int>()); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp new file mode 100644 index 00000000000..12a6f90e889 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.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 istream_iterator + +// istream_iterator(istream_type& s); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator<int> i(inf); + assert(i != std::istream_iterator<int>()); + assert(inf.peek() == ' '); + assert(inf.good()); + int j = 0; + inf >> j; + assert(j == 23); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp new file mode 100644 index 00000000000..5c4ddcad32e --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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 istream_iterator + +// const T* operator->() const; + +#include <iterator> +#include <sstream> +#include <cassert> + +struct A +{ + double d_; + int i_; +}; + +std::istream& operator>>(std::istream& is, A& a) +{ + return is >> a.d_ >> a.i_; +} + +int main() +{ + std::istringstream inf("1.5 23 "); + std::istream_iterator<A> i(inf); + assert(i->d_ == 1.5); + assert(i->i_ == 23); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp new file mode 100644 index 00000000000..e6f86d48336 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.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 istream_iterator + +// const T& operator*() const; + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator<int> i(inf); + int j = 0; + j = *i; + assert(j == 1); + j = *i; + assert(j == 1); + ++i; + j = *i; + assert(j == 23); + j = *i; + assert(j == 23); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp new file mode 100644 index 00000000000..0bee916d50c --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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 istream_iterator + +// template <class T, class charT, class traits, class Distance> +// bool operator==(const istream_iterator<T,charT,traits,Distance> &x, +// const istream_iterator<T,charT,traits,Distance> &y); +// +// template <class T, class charT, class traits, class Distance> +// bool operator!=(const istream_iterator<T,charT,traits,Distance> &x, +// const istream_iterator<T,charT,traits,Distance> &y); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::istringstream inf1(" 1 23"); + std::istringstream inf2(" 1 23"); + std::istream_iterator<int> i1(inf1); + std::istream_iterator<int> i2(inf1); + std::istream_iterator<int> i3(inf2); + std::istream_iterator<int> i4; + std::istream_iterator<int> i5; + assert(i1 == i1); + assert(i1 == i2); + assert(i1 != i3); + assert(i1 != i4); + assert(i1 != i5); + + assert(i2 == i2); + assert(i2 != i3); + assert(i2 != i4); + assert(i2 != i5); + + assert(i3 == i3); + assert(i3 != i4); + assert(i3 != i5); + + assert(i4 == i4); + assert(i4 == i5); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp new file mode 100644 index 00000000000..f5c49e37918 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.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 istream_iterator + +// istream_iterator operator++(int); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator<int> i(inf); + std::istream_iterator<int> icopy = i++; + assert(icopy == i); + int j = 0; + j = *i; + assert(j == 23); + j = 0; + j = *icopy; + assert(j == 1); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp new file mode 100644 index 00000000000..87173f7dc18 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 istream_iterator + +// istream_iterator& operator++(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::istringstream inf(" 1 23"); + std::istream_iterator<int> i(inf); + std::istream_iterator<int>& iref = ++i; + assert(&iref == &i); + int j = 0; + j = *i; + assert(j == 23); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp new file mode 100644 index 00000000000..be55c97773d --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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 T, class charT = char, class traits = char_traits<charT>, +// class Distance = ptrdiff_t> +// class istream_iterator +// : public iterator<input_iterator_tag, T, Distance, const T*, const T&> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef basic_istream<charT,traits> istream_type; +// ... + +#include <iterator> +#include <type_traits> + +int main() +{ + typedef std::istream_iterator<double> I1; + static_assert((std::is_convertible<I1, + std::iterator<std::input_iterator_tag, double, std::ptrdiff_t, + const double*, const double&> >::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::istream_type, std::istream>::value), ""); + typedef std::istream_iterator<unsigned, wchar_t> I2; + static_assert((std::is_convertible<I2, + std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t, + const unsigned*, const unsigned&> >::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::istream_type, std::wistream>::value), ""); +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp new file mode 100644 index 00000000000..d1eabbacef2 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.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> + +// istreambuf_iterator + +// istreambuf_iterator() throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istreambuf_iterator<char> i; + assert(i == std::istreambuf_iterator<char>()); + } + { + std::istreambuf_iterator<wchar_t> i; + assert(i == std::istreambuf_iterator<wchar_t>()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp new file mode 100644 index 00000000000..69e98265e2f --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// istreambuf_iterator(basic_istream<charT,traits>& s) throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf; + std::istreambuf_iterator<char> i(inf); + assert(i == std::istreambuf_iterator<char>()); + } + { + std::istringstream inf("a"); + std::istreambuf_iterator<char> i(inf); + assert(i != std::istreambuf_iterator<char>()); + } + { + std::wistringstream inf; + std::istreambuf_iterator<wchar_t> i(inf); + assert(i == std::istreambuf_iterator<wchar_t>()); + } + { + std::wistringstream inf(L"a"); + std::istreambuf_iterator<wchar_t> i(inf); + assert(i != std::istreambuf_iterator<wchar_t>()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp new file mode 100644 index 00000000000..f5a5fa0c643 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// istreambuf_iterator(const proxy& p) throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator<char> j(inf); + std::istreambuf_iterator<char> i = j++; + assert(i != std::istreambuf_iterator<char>()); + assert(*i == 'b'); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator<wchar_t> j(inf); + std::istreambuf_iterator<wchar_t> i = j++; + assert(i != std::istreambuf_iterator<wchar_t>()); + assert(*i == L'b'); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp new file mode 100644 index 00000000000..020b4f24bce --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// istreambuf_iterator(basic_streambuf<charT,traits>* s) throw(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istreambuf_iterator<char> i(nullptr); + assert(i == std::istreambuf_iterator<char>()); + } + { + std::istringstream inf; + std::istreambuf_iterator<char> i(inf.rdbuf()); + assert(i == std::istreambuf_iterator<char>()); + } + { + std::istringstream inf("a"); + std::istreambuf_iterator<char> i(inf.rdbuf()); + assert(i != std::istreambuf_iterator<char>()); + } + { + std::istreambuf_iterator<wchar_t> i(nullptr); + assert(i == std::istreambuf_iterator<wchar_t>()); + } + { + std::wistringstream inf; + std::istreambuf_iterator<wchar_t> i(inf.rdbuf()); + assert(i == std::istreambuf_iterator<wchar_t>()); + } + { + std::wistringstream inf(L"a"); + std::istreambuf_iterator<wchar_t> i(inf.rdbuf()); + assert(i != std::istreambuf_iterator<wchar_t>()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp new file mode 100644 index 00000000000..2005d303fb3 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// bool equal(istreambuf_iterator<charT,traits>& b) const; + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf1("abc"); + std::istringstream inf2("def"); + std::istreambuf_iterator<char> i1(inf1); + std::istreambuf_iterator<char> i2(inf2); + std::istreambuf_iterator<char> i3; + std::istreambuf_iterator<char> i4; + + assert( i1.equal(i1)); + assert( i1.equal(i2)); + assert(!i1.equal(i3)); + assert(!i1.equal(i4)); + + assert( i2.equal(i1)); + assert( i2.equal(i2)); + assert(!i2.equal(i3)); + assert(!i2.equal(i4)); + + assert(!i3.equal(i1)); + assert(!i3.equal(i2)); + assert( i3.equal(i3)); + assert( i3.equal(i4)); + + assert(!i4.equal(i1)); + assert(!i4.equal(i2)); + assert( i4.equal(i3)); + assert( i4.equal(i4)); + } + { + std::wistringstream inf1(L"abc"); + std::wistringstream inf2(L"def"); + std::istreambuf_iterator<wchar_t> i1(inf1); + std::istreambuf_iterator<wchar_t> i2(inf2); + std::istreambuf_iterator<wchar_t> i3; + std::istreambuf_iterator<wchar_t> i4; + + assert( i1.equal(i1)); + assert( i1.equal(i2)); + assert(!i1.equal(i3)); + assert(!i1.equal(i4)); + + assert( i2.equal(i1)); + assert( i2.equal(i2)); + assert(!i2.equal(i3)); + assert(!i2.equal(i4)); + + assert(!i3.equal(i1)); + assert(!i3.equal(i2)); + assert( i3.equal(i3)); + assert( i3.equal(i4)); + + assert(!i4.equal(i1)); + assert(!i4.equal(i2)); + assert( i4.equal(i3)); + assert( i4.equal(i4)); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp new file mode 100644 index 00000000000..5e8536423d8 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// template <class charT, class traits> +// bool operator!=(const istreambuf_iterator<charT,traits>& a, +// const istreambuf_iterator<charT,traits>& b); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf1("abc"); + std::istringstream inf2("def"); + std::istreambuf_iterator<char> i1(inf1); + std::istreambuf_iterator<char> i2(inf2); + std::istreambuf_iterator<char> i3; + std::istreambuf_iterator<char> i4; + + assert(!(i1 != i1)); + assert(!(i1 != i2)); + assert( (i1 != i3)); + assert( (i1 != i4)); + + assert(!(i2 != i1)); + assert(!(i2 != i2)); + assert( (i2 != i3)); + assert( (i2 != i4)); + + assert( (i3 != i1)); + assert( (i3 != i2)); + assert(!(i3 != i3)); + assert(!(i3 != i4)); + + assert( (i4 != i1)); + assert( (i4 != i2)); + assert(!(i4 != i3)); + assert(!(i4 != i4)); + } + { + std::wistringstream inf1(L"abc"); + std::wistringstream inf2(L"def"); + std::istreambuf_iterator<wchar_t> i1(inf1); + std::istreambuf_iterator<wchar_t> i2(inf2); + std::istreambuf_iterator<wchar_t> i3; + std::istreambuf_iterator<wchar_t> i4; + + assert(!(i1 != i1)); + assert(!(i1 != i2)); + assert( (i1 != i3)); + assert( (i1 != i4)); + + assert(!(i2 != i1)); + assert(!(i2 != i2)); + assert( (i2 != i3)); + assert( (i2 != i4)); + + assert( (i3 != i1)); + assert( (i3 != i2)); + assert(!(i3 != i3)); + assert(!(i3 != i4)); + + assert( (i4 != i1)); + assert( (i4 != i2)); + assert(!(i4 != i3)); + assert(!(i4 != i4)); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp new file mode 100644 index 00000000000..19fb02fc46c --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// charT operator*() const + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator<char> i(inf); + assert(*i == 'a'); + ++i; + assert(*i == 'b'); + ++i; + assert(*i == 'c'); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator<wchar_t> i(inf); + assert(*i == L'a'); + ++i; + assert(*i == L'b'); + ++i; + assert(*i == L'c'); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp new file mode 100644 index 00000000000..919576920ef --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// template <class charT, class traits> +// bool operator==(const istreambuf_iterator<charT,traits>& a, +// const istreambuf_iterator<charT,traits>& b); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf1("abc"); + std::istringstream inf2("def"); + std::istreambuf_iterator<char> i1(inf1); + std::istreambuf_iterator<char> i2(inf2); + std::istreambuf_iterator<char> i3; + std::istreambuf_iterator<char> i4; + + assert( (i1 == i1)); + assert( (i1 == i2)); + assert(!(i1 == i3)); + assert(!(i1 == i4)); + + assert( (i2 == i1)); + assert( (i2 == i2)); + assert(!(i2 == i3)); + assert(!(i2 == i4)); + + assert(!(i3 == i1)); + assert(!(i3 == i2)); + assert( (i3 == i3)); + assert( (i3 == i4)); + + assert(!(i4 == i1)); + assert(!(i4 == i2)); + assert( (i4 == i3)); + assert( (i4 == i4)); + } + { + std::wistringstream inf1(L"abc"); + std::wistringstream inf2(L"def"); + std::istreambuf_iterator<wchar_t> i1(inf1); + std::istreambuf_iterator<wchar_t> i2(inf2); + std::istreambuf_iterator<wchar_t> i3; + std::istreambuf_iterator<wchar_t> i4; + + assert( (i1 == i1)); + assert( (i1 == i2)); + assert(!(i1 == i3)); + assert(!(i1 == i4)); + + assert( (i2 == i1)); + assert( (i2 == i2)); + assert(!(i2 == i3)); + assert(!(i2 == i4)); + + assert(!(i3 == i1)); + assert(!(i3 == i2)); + assert( (i3 == i3)); + assert( (i3 == i4)); + + assert(!(i4 == i1)); + assert(!(i4 == i2)); + assert( (i4 == i3)); + assert( (i4 == i4)); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp new file mode 100644 index 00000000000..e3bf5e2bd84 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// pointer operator->() const; + +#include <iostream> +#include <sstream> +#include <streambuf> + +typedef char C; +int main () +{ + std::istringstream s("filename"); + std::istreambuf_iterator<char> i(s); + + (*i).~C(); // This is well-formed... + i->~C(); // ... so this should be supported! +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp new file mode 100644 index 00000000000..2e4f52ce71b --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// istreambuf_iterator + +// proxy istreambuf_iterator<charT,traits>::operator++(int); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator<char> i(inf); + assert(*i++ == 'a'); + assert(*i++ == 'b'); + assert(*i++ == 'c'); + assert(i == std::istreambuf_iterator<char>()); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator<wchar_t> i(inf); + assert(*i++ == L'a'); + assert(*i++ == L'b'); + assert(*i++ == L'c'); + assert(i == std::istreambuf_iterator<wchar_t>()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp new file mode 100644 index 00000000000..cb7960a0e4e --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_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> + +// istreambuf_iterator + +// istreambuf_iterator<charT,traits>& +// istreambuf_iterator<charT,traits>::operator++(); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator<char> i(inf); + assert(*i == 'a'); + assert(*++i == 'b'); + assert(*++i == 'c'); + assert(++i == std::istreambuf_iterator<char>()); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator<wchar_t> i(inf); + assert(*i == L'a'); + assert(*++i == L'b'); + assert(*++i == L'c'); + assert(++i == std::istreambuf_iterator<wchar_t>()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp new file mode 100644 index 00000000000..acaf2f569b1 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.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 istreambuf_iterator +// : public iterator<input_iterator_tag, charT, +// typename traits::off_type, charT*, +// charT> +// { +// public: +// ... +// proxy operator++(int); + +// class proxy +// { +// public: +// charT operator*(); +// }; + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::istringstream inf("abc"); + std::istreambuf_iterator<char> i(inf); + assert(*i++ == 'a'); + } + { + std::wistringstream inf(L"abc"); + std::istreambuf_iterator<wchar_t> i(inf); + assert(*i++ == L'a'); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp new file mode 100644 index 00000000000..75894a82f59 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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 istreambuf_iterator +// : public iterator<input_iterator_tag, charT, +// typename traits::off_type, unspecified, +// charT> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits::int_type int_type; +// typedef basic_streambuf<charT,traits> streambuf_type; +// typedef basic_istream<charT,traits> istream_type; +// ... + +#include <iterator> +#include <string> +#include <type_traits> + +int main() +{ + typedef std::istreambuf_iterator<char> I1; + static_assert((std::is_convertible<I1, + std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type, + char*, char> >::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::int_type, I1::traits_type::int_type>::value), ""); + static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), ""); + static_assert((std::is_same<I1::istream_type, std::istream>::value), ""); + + typedef std::istreambuf_iterator<wchar_t> I2; + static_assert((std::is_convertible<I2, + std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type, + wchar_t*, wchar_t> >::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::int_type, I2::traits_type::int_type>::value), ""); + static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), ""); + static_assert((std::is_same<I2::istream_type, std::wistream>::value), ""); +} diff --git a/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp b/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp new file mode 100644 index 00000000000..42c8c3dd93d --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 T, size_t N> T* begin(T (&array)[N]); + +#include <iterator> +#include <cassert> + +int main() +{ + int ia[] = {1, 2, 3}; + int* i = std::begin(ia); + assert(*i == 1); + *i = 2; + assert(ia[0] == 2); +} diff --git a/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp b/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp new file mode 100644 index 00000000000..7dca8b071e1 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 C> auto begin(const C& c) -> decltype(c.begin()); + +#include <vector> +#include <cassert> + +int main() +{ + int ia[] = {1, 2, 3}; + const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector<int>::const_iterator i = begin(v); + assert(*i == 1); +} diff --git a/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp b/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp new file mode 100644 index 00000000000..de4c8b0f247 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 C> auto begin(C& c) -> decltype(c.begin()); + +#include <vector> +#include <cassert> + +int main() +{ + int ia[] = {1, 2, 3}; + std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector<int>::iterator i = begin(v); + assert(*i == 1); + *i = 2; + assert(*i == 2); +} diff --git a/libcxx/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp b/libcxx/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp new file mode 100644 index 00000000000..628e5e901e6 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 T, size_t N> T* end(T (&array)[N]); + +#include <iterator> +#include <cassert> + +int main() +{ + int ia[] = {1, 2, 3}; + int* i = std::begin(ia); + int* e = std::end(ia); + assert(e == ia + 3); + assert(e - i == 3); +} diff --git a/libcxx/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp b/libcxx/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp new file mode 100644 index 00000000000..7fa26171f10 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 C> auto end(const C& c) -> decltype(c.end()); + +#include <vector> +#include <cassert> + +int main() +{ + int ia[] = {1, 2, 3}; + const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector<int>::const_iterator i = end(v); + assert(i == v.cend()); +} diff --git a/libcxx/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp b/libcxx/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp new file mode 100644 index 00000000000..8c75433638f --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 C> auto end(C& c) -> decltype(c.end()); + +#include <vector> +#include <cassert> + +int main() +{ + int ia[] = {1, 2, 3}; + std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0])); + std::vector<int>::iterator i = end(v); + assert(i == v.end()); +} diff --git a/libcxx/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp b/libcxx/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp new file mode 100644 index 00000000000..88624581df9 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 ostream_iterator + +// ostream_iterator(const ostream_iterator& x); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::ostringstream outf; + std::ostream_iterator<int> i(outf); + std::ostream_iterator<int> j = i; + assert(outf.good()); +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp new file mode 100644 index 00000000000..321cfbdb82c --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 ostream_iterator + +// ostream_iterator(ostream_type& s); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::ostringstream outf; + std::ostream_iterator<int> i(outf); + assert(outf.good()); +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp new file mode 100644 index 00000000000..8e5c771a4ab --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.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 ostream_iterator + +// ostream_iterator(ostream_type& s, const charT* delimiter); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostream_iterator<int> i(outf, ", "); + assert(outf.good()); + } + { + std::wostringstream outf; + std::ostream_iterator<double, wchar_t> i(outf, L", "); + assert(outf.good()); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp new file mode 100644 index 00000000000..02ef571a06f --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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 ostream_iterator + +// ostream_iterator& operator=(const T& value); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + { + std::ostringstream outf; + std::ostream_iterator<int> i(outf); + i = 2.4; + assert(outf.str() == "2"); + } + { + std::ostringstream outf; + std::ostream_iterator<int> i(outf, ", "); + i = 2.4; + assert(outf.str() == "2, "); + } + { + std::wostringstream outf; + std::ostream_iterator<int, wchar_t> i(outf); + i = 2.4; + assert(outf.str() == L"2"); + } + { + std::wostringstream outf; + std::ostream_iterator<int, wchar_t> i(outf, L", "); + i = 2.4; + assert(outf.str() == L"2, "); + } +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp new file mode 100644 index 00000000000..322107528f4 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 ostream_iterator + +// ostream_iterator& operator*() const; + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::ostringstream os; + std::ostream_iterator<int> i(os); + std::ostream_iterator<int>& iref = *i; + assert(&iref == &i); +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp new file mode 100644 index 00000000000..00b63e8da9b --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 ostream_iterator + +// ostream_iterator& operator++(); +// ostream_iterator& operator++(int); + +#include <iterator> +#include <sstream> +#include <cassert> + +int main() +{ + std::ostringstream os; + std::ostream_iterator<int> i(os); + std::ostream_iterator<int>& iref1 = ++i; + assert(&iref1 == &i); + std::ostream_iterator<int>& iref2 = i++; + assert(&iref2 == &i); +} diff --git a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp new file mode 100644 index 00000000000..460da642bc6 --- /dev/null +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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 T, class charT = char, class traits = char_traits<charT>, +// class Distance = ptrdiff_t> +// class ostream_iterator +// : public iterator<output_iterator_tag, void, void, void, void> +// { +// public: +// typedef charT char_type; +// typedef traits traits_type; +// typedef basic_istream<charT,traits> istream_type; +// ... + +#include <iterator> +#include <type_traits> + +int main() +{ + typedef std::ostream_iterator<double> 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::ostream_type, std::ostream>::value), ""); + typedef std::ostream_iterator<unsigned, 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::ostream_type, std::wostream>::value), ""); +} 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), ""); +} |

