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.strstreambuf/depr.strstreambuf.cons | |
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.strstreambuf/depr.strstreambuf.cons')
8 files changed, 490 insertions, 0 deletions
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); + } +} |