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/depr/depr.str.strstreams/depr.strstream | |
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/depr/depr.str.strstreams/depr.strstream')
7 files changed, 242 insertions, 0 deletions
diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp new file mode 100644 index 000000000000..2a4c0ec5aa20 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream + +// strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "123 4.5 dog"; + std::strstream inout(buf, 0); + assert(inout.str() == std::string("123 4.5 dog")); + int i = 321; + double d = 5.5; + std::string s("cat"); + inout >> i; + assert(inout.fail()); + inout.clear(); + inout << i << ' ' << d << ' ' << s; + assert(inout.str() == std::string("321 5.5 cat")); + i = 0; + d = 0; + s = ""; + inout >> i >> d >> s; + assert(i == 321); + assert(d == 5.5); + assert(s == "cat"); + } + { + char buf[23] = "123 4.5 dog"; + std::strstream inout(buf, 11, std::ios::app); + assert(inout.str() == std::string("123 4.5 dog")); + int i = 0; + double d = 0; + std::string s; + inout >> i >> d >> s; + assert(i == 123); + assert(d == 4.5); + assert(s == "dog"); + i = 321; + d = 5.5; + s = "cat"; + inout.clear(); + inout << i << ' ' << d << ' ' << s; + assert(inout.str() == std::string("123 4.5 dog321 5.5 cat")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp new file mode 100644 index 000000000000..2ec5e7f748e1 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream + +// strstream(); + +#include <strstream> +#include <cassert> + +int main() +{ + std::strstream inout; + int i = 123; + double d = 4.5; + std::string s("dog"); + inout << i << ' ' << d << ' ' << s << std::ends; + assert(inout.str() == std::string("123 4.5 dog")); + i = 0; + d = 0; + s = ""; + inout >> i >> d >> s; + assert(i == 123); + assert(d == 4.5); + assert(strcmp(s.c_str(), "dog") == 0); + inout.freeze(false); +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp new file mode 100644 index 000000000000..4adb179b3dda --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream + +// strstreambuf* rdbuf() const; + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "123 4.5 dog"; + const std::strstream out(buf, 0); + std::strstreambuf* sb = out.rdbuf(); + assert(sb->sputc('a') == 'a'); + assert(buf == std::string("a23 4.5 dog")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp new file mode 100644 index 000000000000..47343388501d --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream + +// void freeze(bool freezefl = true); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstream out; + out.freeze(); + assert(!out.fail()); + out << 'a'; + assert(out.fail()); + out.clear(); + out.freeze(false); + out << 'a'; + out << char(0); + assert(out.str() == std::string("a")); + out.freeze(false); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp new file mode 100644 index 000000000000..18b6350d58c0 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream + +// int pcount() const; + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstream out; + assert(out.pcount() == 0); + out << 123 << ' ' << 4.5 << ' ' << "dog"; + assert(out.pcount() == 11); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp new file mode 100644 index 000000000000..5c273dc45d2d --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream + +// char* str(); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstream out; + out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends; + assert(out.str() == std::string("123 4.5 dog")); + out.freeze(false); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstream/types.pass.cpp new file mode 100644 index 000000000000..67ea32432248 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstream/types.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstream +// : public basic_iostream<char> +// { +// public: +// // Types +// typedef char char_type; +// typedef char_traits<char>::int_type int_type; +// typedef char_traits<char>::pos_type pos_type; +// typedef char_traits<char>::off_type off_type; + +#include <strstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::iostream, std::strstream>::value), ""); + static_assert((std::is_same<std::strstream::char_type, char>::value), ""); + static_assert((std::is_same<std::strstream::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::strstream::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::strstream::off_type, std::char_traits<char>::off_type>::value), ""); +} |