diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/input.output/iostream.format/input.streams/iostreamclass | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) | |
download | src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.tar.gz src-61b9a7258a7693d7f3674a5a1daf7b036ff1d382.zip |
Import libc++ 3.7.0 release (r246257).vendor/libc++/libc++-release_370-r246257
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=287518
svn path=/vendor/libc++/libc++-release_370-r246257/; revision=287519; tag=vendor/libc++/libc++-release_370-r246257
Diffstat (limited to 'test/std/input.output/iostream.format/input.streams/iostreamclass')
6 files changed, 359 insertions, 0 deletions
diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp new file mode 100644 index 000000000000..f4d425728b77 --- /dev/null +++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// void swap(basic_iostream& rhs); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_iostream + : public std::basic_iostream<CharT> +{ + typedef std::basic_iostream<CharT> base; + test_iostream(testbuf<CharT>* sb) : base(sb) {} + + void swap(test_iostream& s) {base::swap(s);} +}; + +int main() +{ + { + testbuf<char> sb1; + testbuf<char> sb2; + test_iostream<char> is1(&sb1); + test_iostream<char> is2(&sb2); + is1.swap(is2); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_iostream<wchar_t> is1(&sb1); + test_iostream<wchar_t> is2(&sb2); + is1.swap(is2); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } +} diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp new file mode 100644 index 000000000000..2032e935bfac --- /dev/null +++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// basic_iostream& operator=(basic_iostream&& rhs); + +#include <istream> +#include <cassert> + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_iostream + : public std::basic_iostream<CharT> +{ + typedef std::basic_iostream<CharT> base; + test_iostream(testbuf<CharT>* sb) : base(sb) {} + + test_iostream& operator=(test_iostream&& s) + {base::operator=(std::move(s)); return *this;} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + testbuf<char> sb1; + testbuf<char> sb2; + test_iostream<char> is1(&sb1); + test_iostream<char> is2(&sb2); + is2 = (std::move(is1)); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb1; + testbuf<wchar_t> sb2; + test_iostream<wchar_t> is1(&sb1); + test_iostream<wchar_t> is2(&sb2); + is2 = (std::move(is1)); + assert(is1.rdbuf() == &sb1); + assert(is1.tie() == 0); + assert(is1.fill() == ' '); + assert(is1.rdstate() == is1.goodbit); + assert(is1.exceptions() == is1.goodbit); + assert(is1.flags() == (is1.skipws | is1.dec)); + assert(is1.precision() == 6); + assert(is1.getloc().name() == "C"); + assert(is2.rdbuf() == &sb2); + assert(is2.tie() == 0); + assert(is2.fill() == ' '); + assert(is2.rdstate() == is2.goodbit); + assert(is2.exceptions() == is2.goodbit); + assert(is2.flags() == (is2.skipws | is2.dec)); + assert(is2.precision() == 6); + assert(is2.getloc().name() == "C"); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp new file mode 100644 index 000000000000..c0592e927c8f --- /dev/null +++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.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. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// basic_iostream(basic_iostream&& rhs); + +#include <istream> +#include <cassert> + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +template <class CharT> +struct test_iostream + : public std::basic_iostream<CharT> +{ + typedef std::basic_iostream<CharT> base; + test_iostream(testbuf<CharT>* sb) : base(sb) {} + + test_iostream(test_iostream&& s) + : base(std::move(s)) {} +}; + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + testbuf<char> sb; + test_iostream<char> is1(&sb); + test_iostream<char> is(std::move(is1)); + assert(is1.rdbuf() == &sb); + assert(is1.gcount() == 0); + assert(is.gcount() == 0); + assert(is.rdbuf() == 0); + assert(is.tie() == 0); + assert(is.fill() == ' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + } + { + testbuf<wchar_t> sb; + test_iostream<wchar_t> is1(&sb); + test_iostream<wchar_t> is(std::move(is1)); + assert(is1.gcount() == 0); + assert(is.gcount() == 0); + assert(is1.rdbuf() == &sb); + assert(is.rdbuf() == 0); + assert(is.tie() == 0); + assert(is.fill() == L' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp new file mode 100644 index 000000000000..dacc8d26d76e --- /dev/null +++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream; + +// explicit basic_iostream(basic_streambuf<charT,traits>* sb); + +#include <istream> +#include <cassert> + +template <class CharT> +struct testbuf + : public std::basic_streambuf<CharT> +{ + testbuf() {} +}; + +int main() +{ + { + testbuf<char> sb; + std::basic_iostream<char> is(&sb); + assert(is.rdbuf() == &sb); + assert(is.tie() == 0); + assert(is.fill() == ' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + assert(is.gcount() == 0); + } + { + testbuf<wchar_t> sb; + std::basic_iostream<wchar_t> is(&sb); + assert(is.rdbuf() == &sb); + assert(is.tie() == 0); + assert(is.fill() == L' '); + assert(is.rdstate() == is.goodbit); + assert(is.exceptions() == is.goodbit); + assert(is.flags() == (is.skipws | is.dec)); + assert(is.precision() == 6); + assert(is.getloc().name() == "C"); + assert(is.gcount() == 0); + } +} diff --git a/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/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/test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp b/test/std/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp new file mode 100644 index 000000000000..6890f1cf7c17 --- /dev/null +++ b/test/std/input.output/iostream.format/input.streams/iostreamclass/types.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. +// +//===----------------------------------------------------------------------===// + +// <istream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_iostream : +// public basic_istream<charT,traits>, +// public basic_ostream<charT,traits> +// { +// public: +// // types: +// typedef charT char_type; +// typedef traits traits_type; +// typedef typename traits_type::int_type int_type; +// typedef typename traits_type::pos_type pos_type; +// typedef typename traits_type::off_type off_type; + +#include <istream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::basic_istream<char>, std::basic_iostream<char> >::value), ""); + static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_iostream<char> >::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_iostream<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} |