diff options
Diffstat (limited to 'test/std/input.output/stream.buffers/streambuf/streambuf.members')
15 files changed, 676 insertions, 0 deletions
diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/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/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp new file mode 100644 index 0000000000000..2c77f25c2e591 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// pos_type pubseekoff(off_type off, ios_base::seekdir way, +// ios_base::openmode which = ios_base::in | ios_base::out); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubseekoff(0, std::ios_base::beg) == -1); + assert(t.pubseekoff(0, std::ios_base::beg, std::ios_base::app) == -1); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp new file mode 100644 index 0000000000000..0b9ddff4106c2 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// pos_type pubseekpos(pos_type sp, +// ios_base::openmode which = ios_base::in | ios_base::out; + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubseekpos(0, std::ios_base::app) == -1); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp new file mode 100644 index 0000000000000..8cf62771e4990 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// basic_streambuf* pubsetbuf(char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubsetbuf(0, 0) == &t); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp new file mode 100644 index 0000000000000..cc16790716100 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int pubsync(); + +#include <streambuf> +#include <cassert> + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} +}; + +int main() +{ + { + test<char> t; + assert(t.pubsync() == 0); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp new file mode 100644 index 0000000000000..95dd2db75b6bb --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: locale.en_US.UTF-8 +// REQUIRES: locale.fr_FR.UTF-8 + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// locale pubimbue(const locale& loc); +// locale getloc() const; + +#include <streambuf> +#include <cassert> + +#include "platform_support.h" // locale name macros + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + test() {} + + void imbue(const std::locale&) + { + assert(this->getloc().name() == LOCALE_en_US_UTF_8); + } +}; + +int main() +{ + { + test<char> t; + assert(t.getloc().name() == "C"); + } + std::locale::global(std::locale(LOCALE_en_US_UTF_8)); + { + test<char> t; + assert(t.getloc().name() == LOCALE_en_US_UTF_8); + assert(t.pubimbue(std::locale(LOCALE_fr_FR_UTF_8)).name() == + LOCALE_en_US_UTF_8); + assert(t.getloc().name() == LOCALE_fr_FR_UTF_8); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp new file mode 100644 index 0000000000000..200150639b911 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize in_avail(); + +#include <streambuf> +#include <cassert> + +int showmanyc_called = 0; + +template <class CharT> +struct test + : public std::basic_streambuf<CharT> +{ + typedef std::basic_streambuf<CharT> base; + + test() {} + + void setg(CharT* gbeg, CharT* gnext, CharT* gend) + { + base::setg(gbeg, gnext, gend); + } +protected: + std::streamsize showmanyc() + { + ++showmanyc_called; + return 5; + } +}; + +int main() +{ + { + test<char> t; + assert(t.in_avail() == 5); + assert(showmanyc_called == 1); + char in[5]; + t.setg(in, in+2, in+5); + assert(t.in_avail() == 3); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp new file mode 100644 index 0000000000000..ac6d0cc932ae9 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sbumpc(); + +#include <streambuf> +#include <cassert> + +int uflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type uflow() + { + ++uflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(uflow_called == 0); + assert(t.sbumpc() == 'a'); + assert(uflow_called == 1); + char in[] = "ABC"; + t.setg(in, in, in+sizeof(in)); + assert(t.sbumpc() == 'A'); + assert(uflow_called == 1); + assert(t.sbumpc() == 'B'); + assert(uflow_called == 1); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp new file mode 100644 index 0000000000000..c68930cfa84c6 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sgetc(); + +#include <streambuf> +#include <cassert> + +int underflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type underflow() + { + ++underflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(underflow_called == 0); + assert(t.sgetc() == 'a'); + assert(underflow_called == 1); + char in[] = "ABC"; + t.setg(in, in, in+sizeof(in)); + assert(t.sgetc() == 'A'); + assert(underflow_called == 1); + assert(t.sgetc() == 'A'); + assert(underflow_called == 1); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp new file mode 100644 index 0000000000000..730cedeea76c0 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize sgetn(char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +int xsgetn_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + test() {} + +protected: + std::streamsize xsgetn(char_type* s, std::streamsize n) + { + ++xsgetn_called; + return 10; + } +}; + +int main() +{ + test t; + assert(xsgetn_called == 0); + assert(t.sgetn(0, 0) == 10); + assert(xsgetn_called == 1); +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp new file mode 100644 index 0000000000000..7f44245e26e39 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type snextc(); + +#include <streambuf> +#include <cassert> + +int uflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type uflow() + { + ++uflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(uflow_called == 0); + assert(t.snextc() == -1); + assert(uflow_called == 1); + char in[] = "ABC"; + t.setg(in, in, in+sizeof(in)); + assert(t.snextc() == 'B'); + assert(uflow_called == 1); + assert(t.snextc() == 'C'); + assert(uflow_called == 1); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp new file mode 100644 index 0000000000000..34a2a2dda3727 --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sputbackc(char_type c); + +#include <streambuf> +#include <cassert> + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type pbackfail(int_type c = traits_type::eof()) + { + ++pbackfail_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(pbackfail_called == 0); + assert(t.sputbackc('A') == 'a'); + assert(pbackfail_called == 1); + char in[] = "ABC"; + t.setg(in, in+1, in+sizeof(in)); + assert(t.sputbackc('A') == 'A'); + assert(pbackfail_called == 1); + assert(t.sputbackc('A') == 'a'); + assert(pbackfail_called == 2); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp new file mode 100644 index 0000000000000..4c68fada07a8c --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sungetc(); + +#include <streambuf> +#include <cassert> + +int pbackfail_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + +protected: + int_type pbackfail(int_type c = traits_type::eof()) + { + ++pbackfail_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(pbackfail_called == 0); + assert(t.sungetc() == 'a'); + assert(pbackfail_called == 1); + char in[] = "ABC"; + t.setg(in, in+1, in+sizeof(in)); + assert(t.sungetc() == 'A'); + assert(pbackfail_called == 1); + assert(t.sungetc() == 'a'); + assert(pbackfail_called == 2); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp new file mode 100644 index 0000000000000..b04b8b0acc91a --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// int_type sputc(char_type c); + +#include <streambuf> +#include <cassert> + +int overflow_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + typedef std::basic_streambuf<char> base; + + test() {} + + void setg(char* gbeg, char* gnext, char* gend) + { + base::setg(gbeg, gnext, gend); + } + void setp(char* pbeg, char* pend) + { + base::setp(pbeg, pend); + } + +protected: + int_type overflow(int_type c = traits_type::eof()) + { + ++overflow_called; + return 'a'; + } +}; + +int main() +{ + { + test t; + assert(overflow_called == 0); + assert(t.sputc('A') == 'a'); + assert(overflow_called == 1); + char out[3] = {0}; + t.setp(out, out+sizeof(out)); + assert(t.sputc('A') == 'A'); + assert(overflow_called == 1); + assert(out[0] == 'A'); + assert(t.sputc('B') == 'B'); + assert(overflow_called == 1); + assert(out[0] == 'A'); + assert(out[1] == 'B'); + } +} diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp new file mode 100644 index 0000000000000..e03e8e0cbda3c --- /dev/null +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.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. +// +//===----------------------------------------------------------------------===// + +// <streambuf> + +// template <class charT, class traits = char_traits<charT> > +// class basic_streambuf; + +// streamsize sputn(const char_type* s, streamsize n); + +#include <streambuf> +#include <cassert> + +int xsputn_called = 0; + +struct test + : public std::basic_streambuf<char> +{ + test() {} + +protected: + std::streamsize xsputn(const char_type* s, std::streamsize n) + { + ++xsputn_called; + return 5; + } +}; + +int main() +{ + test t; + assert(xsputn_called == 0); + assert(t.sputn(0, 0) == 5); + assert(xsputn_called == 1); +} |
