diff options
Diffstat (limited to 'test/std/depr/depr.str.strstreams')
40 files changed, 1600 insertions, 0 deletions
diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp new file mode 100644 index 000000000000..9911df715078 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 istrstream + +// explicit istrstream(const char* s); + +#include <strstream> +#include <cassert> + +int main() +{ + { + const char buf[] = "123 4.5 dog"; + std::istrstream in(buf); + int i; + in >> i; + assert(i == 123); + double d; + in >> d; + assert(d == 4.5); + std::string s; + in >> s; + assert(s == "dog"); + assert(in.eof()); + assert(!in.fail()); + in.clear(); + in.putback('g'); + assert(!in.fail()); + in.putback('g'); + assert(in.fail()); + assert(buf[9] == 'o'); + assert(buf[10] == 'g'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp new file mode 100644 index 000000000000..a80095099401 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 istrstream + +// explicit istrstream(const char* s, streamsize n); + +#include <strstream> +#include <cassert> + +int main() +{ + { + const char buf[] = "123 4.5 dog"; + std::istrstream in(buf, 7); + int i; + in >> i; + assert(i == 123); + double d; + in >> d; + assert(d == 4.5); + std::string s; + in >> s; + assert(s == ""); + assert(in.eof()); + assert(in.fail()); + in.clear(); + in.putback('5'); + assert(!in.fail()); + in.putback('5'); + assert(in.fail()); + assert(buf[5] == '.'); + assert(buf[6] == '5'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp new file mode 100644 index 000000000000..edd6c1f6286c --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 istrstream + +// explicit istrstream(char* s); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "123 4.5 dog"; + std::istrstream in(buf); + int i; + in >> i; + assert(i == 123); + double d; + in >> d; + assert(d == 4.5); + std::string s; + in >> s; + assert(s == "dog"); + assert(in.eof()); + assert(!in.fail()); + in.clear(); + in.putback('g'); + assert(!in.fail()); + in.putback('g'); + assert(!in.fail()); + assert(buf[9] == 'g'); + assert(buf[10] == 'g'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp new file mode 100644 index 000000000000..5d01715ba1b7 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 istrstream + +// explicit istrstream(char* s, streamsize n); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "123 4.5 dog"; + std::istrstream in(buf, 7); + int i; + in >> i; + assert(i == 123); + double d; + in >> d; + assert(d == 4.5); + std::string s; + in >> s; + assert(s == ""); + assert(in.eof()); + assert(in.fail()); + in.clear(); + in.putback('5'); + assert(!in.fail()); + in.putback('5'); + assert(!in.fail()); + assert(buf[5] == '5'); + assert(buf[6] == '5'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp new file mode 100644 index 000000000000..0c273b3460b7 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.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 istrstream + +// strstreambuf* rdbuf() const; + +#include <strstream> +#include <cassert> + +int main() +{ + { + const char buf[] = "123 4.5 dog"; + const std::istrstream in(buf); + std::strstreambuf* sb = in.rdbuf(); + assert(sb->sgetc() == '1'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp new file mode 100644 index 000000000000..deb43d6f6362 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class istrstream + +// char* str(); + +#include <strstream> +#include <cassert> + +int main() +{ + { + const char buf[] = "123 4.5 dog"; + std::istrstream in(buf); + assert(in.str() == std::string("123 4.5 dog")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp new file mode 100644 index 000000000000..4e158c6f0633 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.istrstream/types.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class istrstream +// : public basic_istream<char> +// { +// ... + +#include <strstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::istream, std::istrstream>::value), ""); +} diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp new file mode 100644 index 000000000000..1ad0bfa8e269 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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 ostrstream + +// ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "123 4.5 dog"; + std::ostrstream out(buf, 0); + assert(out.str() == std::string("123 4.5 dog")); + int i = 321; + double d = 5.5; + std::string s("cat"); + out << i << ' ' << d << ' ' << s << std::ends; + assert(out.str() == std::string("321 5.5 cat")); + } + { + char buf[23] = "123 4.5 dog"; + std::ostrstream out(buf, 11, std::ios::app); + assert(out.str() == std::string("123 4.5 dog")); + int i = 321; + double d = 5.5; + std::string s("cat"); + out << i << ' ' << d << ' ' << s << std::ends; + assert(out.str() == std::string("123 4.5 dog321 5.5 cat")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp new file mode 100644 index 000000000000..5ea4988ffa6f --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.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 ostrstream + +// ostrstream(); + +#include <strstream> +#include <cassert> + +int main() +{ + std::ostrstream out; + int i = 123; + double d = 4.5; + std::string s("dog"); + out << i << ' ' << d << ' ' << s << std::ends; + assert(out.str() == std::string("123 4.5 dog")); + out.freeze(false); +} diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp new file mode 100644 index 000000000000..a60c7cba601c --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/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 ostrstream + +// void freeze(bool freezefl = true); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::ostrstream 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.ostrstream/depr.ostrstream.members/pcount.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp new file mode 100644 index 000000000000..4a752d659b82 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/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 ostrstream + +// int pcount() const; + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::ostrstream out; + assert(out.pcount() == 0); + out << 123 << ' ' << 4.5 << ' ' << "dog"; + assert(out.pcount() == 11); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp new file mode 100644 index 000000000000..b8a23b227384 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/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 ostrstream + +// strstreambuf* rdbuf() const; + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "123 4.5 dog"; + const std::ostrstream 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.ostrstream/depr.ostrstream.members/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp new file mode 100644 index 000000000000..9a7160f455d2 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/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 ostrstream + +// char* str(); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::ostrstream 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.ostrstream/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp new file mode 100644 index 000000000000..88ab272a71dc --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.ostrstream/types.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class ostrstream +// : public basic_ostream<char> +// { +// ... + +#include <strstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::ostream, std::ostrstream>::value), ""); +} 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), ""); +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp new file mode 100644 index 000000000000..04eaab5adca7 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstreambuf + +// strstreambuf(const char* gnext_arg, streamsize n); + +#include <strstream> +#include <cassert> + +int main() +{ + { + const char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf)); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == 0); + assert(sb.snextc() == EOF); + } + { + const char buf[] = "abcd"; + std::strstreambuf sb(buf, 0); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp new file mode 100644 index 000000000000..5d345f13dd41 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf)); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == 0); + assert(sb.snextc() == EOF); + } + { + char buf[] = "abcd"; + std::strstreambuf sb(buf, 0); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + } + { + char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf), buf); + assert(sb.sgetc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == 'i'); + assert(sb.sputc('j') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == 'i'); + assert(sb.snextc() == EOF); + } + { + char buf[] = "abcd"; + std::strstreambuf sb(buf, 0, buf); + assert(sb.sgetc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == EOF); + } + { + char buf[10] = "abcd"; + int s = std::strlen(buf); + std::strstreambuf sb(buf, sizeof(buf)-s, buf + s); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == 'i'); + assert(sb.sputc('j') == 'j'); + assert(sb.sputc('j') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == 'i'); + assert(sb.snextc() == 'j'); + assert(sb.snextc() == EOF); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp new file mode 100644 index 000000000000..13ae427a173c --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstreambuf + +// strstreambuf(const signed char* gnext_arg, streamsize n); + +#include <strstream> +#include <cassert> + +int main() +{ + { + const signed char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf)); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == 0); + assert(sb.snextc() == EOF); + } + { + const signed char buf[] = "abcd"; + std::strstreambuf sb(buf, 0); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp new file mode 100644 index 000000000000..3a09711c0fac --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstreambuf + +// strstreambuf(const unsigned char* gnext_arg, streamsize n); + +#include <strstream> +#include <cassert> + +int main() +{ + { + unsigned char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf)); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == 0); + assert(sb.snextc() == EOF); + } + { + unsigned char buf[] = "abcd"; + std::strstreambuf sb(buf, 0); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp new file mode 100644 index 000000000000..12a1fb874c30 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstreambuf + +// strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)); + +#include <strstream> +#include <cassert> + +int called = 0; + +void* my_alloc(std::size_t n) +{ + static char buf[10000]; + ++called; + return buf; +} + +void my_free(void*) +{ + ++called; +} + +struct test + : std::strstreambuf +{ + test(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)) + : std::strstreambuf(palloc_arg, pfree_arg) {} + virtual int_type overflow(int_type c) + {return std::strstreambuf::overflow(c);} +}; + +int main() +{ + { + test s(my_alloc, my_free); + assert(called == 0); + s.overflow('a'); + assert(called == 1); + } + assert(called == 2); +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp new file mode 100644 index 000000000000..1e5635e46ec5 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// explicit strstreambuf(streamsize alsize_arg = 0); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstreambuf s; + assert(s.str() == nullptr); + assert(s.pcount() == 0); + } + { + std::strstreambuf s(1024); + assert(s.str() == nullptr); + assert(s.pcount() == 0); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp new file mode 100644 index 000000000000..c827850abf3a --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0); + +#include <strstream> +#include <cassert> + +int main() +{ + { + signed char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf)); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == 0); + assert(sb.snextc() == EOF); + } + { + signed char buf[] = "abcd"; + std::strstreambuf sb(buf, 0); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + } + { + signed char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf), buf); + assert(sb.sgetc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == 'i'); + assert(sb.sputc('j') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == 'i'); + assert(sb.snextc() == EOF); + } + { + signed char buf[] = "abcd"; + std::strstreambuf sb(buf, 0, buf); + assert(sb.sgetc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == EOF); + } + { + signed char buf[10] = "abcd"; + int s = std::strlen((char*)buf); + std::strstreambuf sb(buf, sizeof(buf)-s, buf + s); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == 'i'); + assert(sb.sputc('j') == 'j'); + assert(sb.sputc('j') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == 'i'); + assert(sb.snextc() == 'j'); + assert(sb.snextc() == EOF); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp new file mode 100644 index 000000000000..46c11e4afaf0 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp @@ -0,0 +1,96 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0); + +#include <strstream> +#include <cassert> + +int main() +{ + { + unsigned char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf)); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == 0); + assert(sb.snextc() == EOF); + } + { + unsigned char buf[] = "abcd"; + std::strstreambuf sb(buf, 0); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + } + { + unsigned char buf[] = "abcd"; + std::strstreambuf sb(buf, sizeof(buf), buf); + assert(sb.sgetc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == 'i'); + assert(sb.sputc('j') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == 'i'); + assert(sb.snextc() == EOF); + } + { + unsigned char buf[] = "abcd"; + std::strstreambuf sb(buf, 0, buf); + assert(sb.sgetc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == EOF); + } + { + unsigned char buf[10] = "abcd"; + int s = std::strlen((char*)buf); + std::strstreambuf sb(buf, sizeof(buf)-s, buf + s); + assert(sb.sgetc() == 'a'); + assert(sb.snextc() == 'b'); + assert(sb.snextc() == 'c'); + assert(sb.snextc() == 'd'); + assert(sb.snextc() == EOF); + assert(sb.sputc('e') == 'e'); + assert(sb.sputc('f') == 'f'); + assert(sb.sputc('g') == 'g'); + assert(sb.sputc('h') == 'h'); + assert(sb.sputc('i') == 'i'); + assert(sb.sputc('j') == 'j'); + assert(sb.sputc('j') == EOF); + assert(sb.sgetc() == 'e'); + assert(sb.snextc() == 'f'); + assert(sb.snextc() == 'g'); + assert(sb.snextc() == 'h'); + assert(sb.snextc() == 'i'); + assert(sb.snextc() == 'j'); + assert(sb.snextc() == EOF); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp new file mode 100644 index 000000000000..9572ef30d41b --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.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 strstreambuf + +// void freeze(bool freezefl = true); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstreambuf sb; + sb.freeze(true); + assert(sb.sputc('a') == EOF); + sb.freeze(false); + assert(sb.sputc('a') == 'a'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp new file mode 100644 index 000000000000..d96f0f769f62 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.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 strstreambuf + +// int pcount() const; + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstreambuf sb; + assert(sb.pcount() == 0); + assert(sb.sputc('a') == 'a'); + assert(sb.pcount() == 1); + assert(sb.sputc(0) == 0); + assert(sb.pcount() == 2); + assert(sb.str() == std::string("a")); + assert(sb.pcount() == 2); + sb.freeze(false); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp new file mode 100644 index 000000000000..27de56f2cef6 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.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 strstreambuf + +// char* str(); + +#include <strstream> +#include <cassert> + +int main() +{ + { + std::strstreambuf sb; + assert(sb.sputc('a') == 'a'); + assert(sb.sputc(0) == 0); + assert(sb.str() == std::string("a")); + sb.freeze(false); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp new file mode 100644 index 000000000000..843450b71ead --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// int_type overflow(int_type c = EOF); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[12] = "abc"; + std::strstreambuf sb(buf, sizeof(buf), buf); + assert(sb.sputc('1') == '1'); + assert(sb.str() == std::string("1bc")); + assert(sb.sputc('2') == '2'); + assert(sb.str() == std::string("12c")); + assert(sb.sputc('3') == '3'); + assert(sb.str() == std::string("123")); + assert(sb.sputc('4') == '4'); + assert(sb.str() == std::string("1234")); + assert(sb.sputc('5') == '5'); + assert(sb.str() == std::string("12345")); + assert(sb.sputc('6') == '6'); + assert(sb.str() == std::string("123456")); + assert(sb.sputc('7') == '7'); + assert(sb.str() == std::string("1234567")); + assert(sb.sputc('8') == '8'); + assert(sb.str() == std::string("12345678")); + assert(sb.sputc('9') == '9'); + assert(sb.str() == std::string("123456789")); + assert(sb.sputc('0') == '0'); + assert(sb.str() == std::string("1234567890")); + assert(sb.sputc('1') == '1'); + assert(sb.str() == std::string("12345678901")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp new file mode 100644 index 000000000000..2a3fe202e308 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// int_type pbackfail(int_type c = EOF); + +#include <strstream> +#include <cassert> + +struct test + : public std::strstreambuf +{ + typedef std::strstreambuf base; + test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0) + : base(gnext_arg, n, pbeg_arg) {} + test(const char* gnext_arg, std::streamsize n) + : base(gnext_arg, n) {} + + virtual int_type pbackfail(int_type c = EOF) {return base::pbackfail(c);} +}; + +int main() +{ + { + const char buf[] = "123"; + test sb(buf, 0); + assert(sb.sgetc() == '1'); + assert(sb.snextc() == '2'); + assert(sb.snextc() == '3'); + assert(sb.sgetc() == '3'); + assert(sb.snextc() == EOF); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail('3') == EOF); + assert(sb.pbackfail('2') == '2'); + assert(sb.pbackfail(EOF) != EOF); + assert(sb.pbackfail(EOF) == EOF); + assert(sb.str() == std::string("123")); + } + { + char buf[] = "123"; + test sb(buf, 0); + assert(sb.sgetc() == '1'); + assert(sb.snextc() == '2'); + assert(sb.snextc() == '3'); + assert(sb.sgetc() == '3'); + assert(sb.snextc() == EOF); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail('3') == '3'); + assert(sb.pbackfail(EOF) != EOF); + assert(sb.pbackfail(EOF) == EOF); + assert(sb.str() == std::string("133")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp new file mode 100644 index 000000000000..27d5d29dbc45 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf + +// pos_type seekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "0123456789"; + std::strstreambuf sb(buf, 0); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(sb.sgetc() == '6'); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(sb.sgetc() == '7'); + } + { + char buf[] = "0123456789"; + std::strstreambuf sb(buf, 0, buf); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3); + assert(sb.sputc('a') == 'a'); + assert(sb.str() == std::string("012a456789")); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7); + assert(sb.sputc('b') == 'b'); + assert(sb.str() == std::string("012a456b89")); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7); + assert(sb.sputc('c') == 'c'); + assert(sb.str() == std::string("012a456c89")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp new file mode 100644 index 000000000000..d412479d850e --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstreambuf + +// pos_type seekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "0123456789"; + std::strstreambuf sb(buf, 0); + assert(sb.pubseekpos(3, std::ios_base::out) == -1); + assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekpos(3, std::ios_base::in) == 3); + assert(sb.sgetc() == '3'); + } + { + char buf[] = "0123456789"; + std::strstreambuf sb(buf, 0, buf); + assert(sb.pubseekpos(3, std::ios_base::in) == 3); + assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3); + assert(sb.pubseekpos(3, std::ios_base::out) == 3); + assert(sb.sputc('a') == 'a'); + assert(sb.str() == std::string("012a456789")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp new file mode 100644 index 000000000000..99eb9e93a0ff --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.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 strstreambuf + +// streambuf* setbuf(char* s, streamsize n); + +#include <strstream> +#include <cassert> + +int main() +{ + { + char buf[] = "0123456789"; + std::strstreambuf sb(buf, 0); + assert(sb.pubsetbuf(0, 0) == &sb); + assert(sb.str() == std::string("0123456789")); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp new file mode 100644 index 000000000000..1b16a37aaf0c --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.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. +// +//===----------------------------------------------------------------------===// + +// <strstream> + +// class strstreambuf + +// int_type underflow(); + +#include <strstream> +#include <cassert> + +struct test + : public std::strstreambuf +{ + typedef std::strstreambuf base; + test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0) + : base(gnext_arg, n, pbeg_arg) {} + test(const char* gnext_arg, std::streamsize n) + : base(gnext_arg, n) {} + + base::int_type underflow() {return base::underflow();} +}; + +int main() +{ + { + char buf[10] = "123"; + test sb(buf, 0, buf + 3); + assert(sb.underflow() == '1'); + assert(sb.underflow() == '1'); + assert(sb.snextc() == '2'); + assert(sb.underflow() == '2'); + assert(sb.underflow() == '2'); + assert(sb.snextc() == '3'); + assert(sb.underflow() == '3'); + assert(sb.underflow() == '3'); + assert(sb.snextc() == EOF); + assert(sb.underflow() == EOF); + assert(sb.underflow() == EOF); + sb.sputc('4'); + assert(sb.underflow() == '4'); + assert(sb.underflow() == '4'); + } +} diff --git a/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp b/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp new file mode 100644 index 000000000000..c4a1562bf869 --- /dev/null +++ b/test/std/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 strstreambuf +// : public basic_streambuf<char> + +#include <strstream> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::streambuf, std::strstreambuf>::value), ""); +} diff --git a/test/std/depr/depr.str.strstreams/version.pass.cpp b/test/std/depr/depr.str.strstreams/version.pass.cpp new file mode 100644 index 000000000000..f27665f15bcd --- /dev/null +++ b/test/std/depr/depr.str.strstreams/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +#include <strstream> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |