diff options
Diffstat (limited to 'libcxx/test/std/input.output/iostreams.base')
92 files changed, 3471 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp new file mode 100644 index 00000000000..1da6d4406c9 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// void state(stateT s); + +#include <ios> +#include <cassert> + +int main() +{ + std::fpos<int> f; + f.state(3); + assert(f.state() == 3); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp new file mode 100644 index 00000000000..a602e3e94be --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/addition.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// Addition + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(5); + std::streamoff o(6); + P q = p + o; + assert(q == P(11)); + p += o; + assert(p == q); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp new file mode 100644 index 00000000000..1b939d86e59 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// fpos(int) + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(5); + assert(p == P(5)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp new file mode 100644 index 00000000000..47ce6870a3b --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/difference.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// Subraction with fpos + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(11); + P q(6); + std::streamoff o = p - q; + assert(o == 5); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp new file mode 100644 index 00000000000..76f8fa12a41 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/eq_int.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// == and != + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(5); + P q(6); + assert(p == p); + assert(p != q); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp new file mode 100644 index 00000000000..9c6ebd9f74e --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// converts to and from streamoff + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(std::streamoff(7)); + std::streamoff offset(p); + assert(offset == 7); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp new file mode 100644 index 00000000000..eb738b492c8 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// streamsize and streamoff interconvert + +#include <ios> +#include <cassert> + +int main() +{ + std::streamoff o(5); + std::streamsize sz(o); + assert(sz == 5); + std::streamoff o2(sz); + assert(o == o2); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp new file mode 100644 index 00000000000..f9e6513e4a4 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/subtraction.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class StateT> class fpos + +// Subraction with offset + +#include <ios> +#include <cassert> + +int main() +{ + typedef std::fpos<std::mbstate_t> P; + P p(11); + std::streamoff o(6); + P q = p - o; + assert(q == P(5)); + p -= o; + assert(p == q); +} diff --git a/libcxx/test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/fpos/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/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp new file mode 100644 index 00000000000..958fcb53d89 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags flags() const; + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.flags() == (test::skipws | test::dec)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp new file mode 100644 index 00000000000..36b5794983e --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags flags(fmtflags fmtfl); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + test::fmtflags f = t.flags(test::hex | test::right); + assert(f == (test::skipws | test::dec)); + assert(t.flags() == (test::hex | test::right)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp new file mode 100644 index 00000000000..701e3de360d --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize precision() const; + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.precision() == 6); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp new file mode 100644 index 00000000000..e0d6484c8fd --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize precision(streamsize prec); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.precision() == 6); + std::streamsize p = t.precision(10); + assert(p == 6); + assert(t.precision() == 10); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp new file mode 100644 index 00000000000..d9ec47b7907 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags setf(fmtflags fmtfl) + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + test::fmtflags f = t.setf(test::hex | test::right); + assert(f == (test::skipws | test::dec)); + assert(t.flags() == (test::skipws | test::dec | test::hex | test::right)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp new file mode 100644 index 00000000000..b201377027d --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// fmtflags setf(fmtflags fmtfl, fmtflags mask); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + test::fmtflags f = t.setf(test::hex | test::right, test::dec | test::right); + assert(f == (test::skipws | test::dec)); + assert(t.flags() == (test::skipws | test::right)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp new file mode 100644 index 00000000000..163fc54a1e8 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// void unsetf(fmtflags mask); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.flags() == (test::skipws | test::dec)); + t.unsetf(test::dec | test::right); + assert(t.flags() == test::skipws); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp new file mode 100644 index 00000000000..287c89d296e --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize width() const; + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.width() == 0); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp new file mode 100644 index 00000000000..6e532deddf0 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// streamsize width(streamsize wide); + +#include <ios> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + assert(t.width() == 0); + std::streamsize w = t.width(4); + assert(w == 0); + assert(t.width() == 4); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp new file mode 100644 index 00000000000..c0ed3150457 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// void register_callback(event_callback fn, int index); + +#include <ios> +#include <string> +#include <locale> +#include <cassert> + +#include "platform_support.h" // locale name macros + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int f1_called = 0; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 4); + ++f1_called; + } +} + +int main() +{ + test t; + std::ios_base& b = t; + b.register_callback(f1, 4); + b.register_callback(f1, 4); + b.register_callback(f1, 4); + std::locale l = b.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(f1_called == 3); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp new file mode 100644 index 00000000000..e6f334808c1 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ~ios_base() + +#include <ios> +#include <string> +#include <locale> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +bool f1_called = false; +bool f2_called = false; +bool f3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert( f2_called); + assert( f3_called); + assert(stream.getloc().name() == "C"); + assert(index == 4); + f1_called = true; + } +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert(!f2_called); + assert( f3_called); + assert(stream.getloc().name() == "C"); + assert(index == 5); + f2_called = true; + } +} + +void f3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert(!f2_called); + assert(!f3_called); + assert(stream.getloc().name() == "C"); + assert(index == 6); + f3_called = true; + } +} + +int main() +{ + { + test t; + std::ios_base& b = t; + b.register_callback(f1, 4); + b.register_callback(f2, 5); + b.register_callback(f3, 6); + } + assert(f1_called); + assert(f2_called); + assert(f3_called); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp new file mode 100644 index 00000000000..8f265bc6988 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.locales/getloc.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// locale getloc() const; + +#include <ios> +#include <string> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + const test t; + assert(t.getloc().name() == std::string("C")); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp new file mode 100644 index 00000000000..4e34c08ab08 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// locale imbue(const locale& loc); + +#include <ios> +#include <string> +#include <locale> +#include <cassert> + +#include "platform_support.h" // locale name macros + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +bool f1_called = false; +bool f2_called = false; +bool f3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert( f2_called); + assert( f3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 4); + f1_called = true; + } +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert(!f2_called); + assert( f3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 5); + f2_called = true; + } +} + +void f3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert(!f2_called); + assert(!f3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 6); + f3_called = true; + } +} + +int main() +{ + test t; + std::ios_base& b = t; + b.register_callback(f1, 4); + b.register_callback(f2, 5); + b.register_callback(f3, 6); + std::locale l = b.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(l.name() == std::string("C")); + assert(b.getloc().name() == std::string(LOCALE_en_US_UTF_8)); + assert(f1_called); + assert(f2_called); + assert(f3_called); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp new file mode 100644 index 00000000000..1e2ee50632a --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// long& iword(int idx); + +#include <ios> +#include <string> +#include <cassert> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + std::ios_base& b = t; + for (int i = 0; i < 10000; ++i) + { + assert(b.iword(i) == 0); + b.iword(i) = i; + assert(b.iword(i) == i); + for (int j = 0; j <= i; ++j) + assert(b.iword(j) == j); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp new file mode 100644 index 00000000000..5246ad8f644 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/pword.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// void*& pword(int idx); + +#include <ios> +#include <string> +#include <cassert> +#include <cstdint> + +class test + : public std::ios +{ +public: + test() + { + init(0); + } +}; + +int main() +{ + test t; + std::ios_base& b = t; + for (std::intptr_t i = 0; i < 10000; ++i) + { + assert(b.pword(i) == 0); + b.pword(i) = (void*)i; + assert(b.pword(i) == (void*)i); + for (std::intptr_t j = 0; j <= i; ++j) + assert(b.pword(j) == (void*)j); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp new file mode 100644 index 00000000000..eb737b1a7dc --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static int xalloc(); + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::xalloc() == 0); + assert(std::ios_base::xalloc() == 1); + assert(std::ios_base::xalloc() == 2); + assert(std::ios_base::xalloc() == 3); + assert(std::ios_base::xalloc() == 4); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp new file mode 100644 index 00000000000..5dc72b1edc0 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// bool sync_with_stdio(bool sync = true); + +#include <ios> +#include <cassert> + +int main() +{ + assert( std::ios_base::sync_with_stdio(false)); + assert(!std::ios_base::sync_with_stdio(false)); + assert(!std::ios_base::sync_with_stdio(true)); + assert( std::ios_base::sync_with_stdio(true)); + assert( std::ios_base::sync_with_stdio()); + assert( std::ios_base::sync_with_stdio(false)); + assert(!std::ios_base::sync_with_stdio()); + assert( std::ios_base::sync_with_stdio()); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.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/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp new file mode 100644 index 00000000000..50f5fdad744 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base::failure + +// explicit failure(const char* msg, const error_code& ec = io_errc::stream); + +#include <ios> +#include <string> +#include <cassert> + +int main() +{ + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg.c_str(), make_error_code(std::errc::is_a_directory)); + assert(se.code() == std::make_error_code(std::errc::is_a_directory)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find("Is a directory") != std::string::npos); + } + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg.c_str()); + assert(se.code() == std::make_error_code(std::io_errc::stream)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find(std::iostream_category().message(static_cast<int> + (std::io_errc::stream))) != std::string::npos); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp new file mode 100644 index 00000000000..5c9abbe5379 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base::failure + +// explicit failure(const string& msg, const error_code& ec = io_errc::stream); + +#include <ios> +#include <string> +#include <cassert> + +int main() +{ + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory)); + assert(se.code() == std::make_error_code(std::errc::is_a_directory)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find("Is a directory") != std::string::npos); + } + { + std::string what_arg("io test message"); + std::ios_base::failure se(what_arg); + assert(se.code() == std::make_error_code(std::io_errc::stream)); + std::string what_message(se.what()); + assert(what_message.find(what_arg) != std::string::npos); + assert(what_message.find(std::iostream_category().message(static_cast<int> + (std::io_errc::stream))) != std::string::npos); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp new file mode 100644 index 00000000000..9f374598ff7 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const fmtflags boolalpha; +// static const fmtflags dec; +// static const fmtflags fixed; +// static const fmtflags hex; +// static const fmtflags internal; +// static const fmtflags left; +// static const fmtflags oct; +// static const fmtflags right; +// static const fmtflags scientific; +// static const fmtflags showbase; +// static const fmtflags showpoint; +// static const fmtflags showpos; +// static const fmtflags skipws; +// static const fmtflags unitbuf; +// static const fmtflags uppercase; +// static const fmtflags adjustfield = left | right | internal; +// static const fmtflags basefield = dec | oct | hex; +// static const fmtflags floatfield = scientific | fixed; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::boolalpha); + assert(std::ios_base::dec); + assert(std::ios_base::fixed); + assert(std::ios_base::hex); + assert(std::ios_base::internal); + assert(std::ios_base::left); + assert(std::ios_base::oct); + assert(std::ios_base::right); + assert(std::ios_base::scientific); + assert(std::ios_base::showbase); + assert(std::ios_base::showpoint); + assert(std::ios_base::showpos); + assert(std::ios_base::skipws); + assert(std::ios_base::unitbuf); + assert(std::ios_base::uppercase); + + assert + ( + ( std::ios_base::boolalpha + & std::ios_base::dec + & std::ios_base::fixed + & std::ios_base::hex + & std::ios_base::internal + & std::ios_base::left + & std::ios_base::oct + & std::ios_base::right + & std::ios_base::scientific + & std::ios_base::showbase + & std::ios_base::showpoint + & std::ios_base::showpos + & std::ios_base::skipws + & std::ios_base::unitbuf + & std::ios_base::uppercase) == 0 + ); + + assert(std::ios_base::adjustfield == (std::ios_base::left + | std::ios_base::right + | std::ios_base::internal)); + assert(std::ios_base::basefield == (std::ios_base::dec + | std::ios_base::oct + | std::ios_base::hex)); + assert(std::ios_base::floatfield == (std::ios_base::scientific + | std::ios_base::fixed)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp new file mode 100644 index 00000000000..55c02f38ce9 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const iostate badbit; +// static const iostate eofbit; +// static const iostate failbit; +// static const iostate goodbit = 0; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::badbit); + assert(std::ios_base::eofbit); + assert(std::ios_base::failbit); + + assert + ( + ( std::ios_base::badbit + & std::ios_base::eofbit + & std::ios_base::failbit) == 0 + ); + + assert(std::ios_base::goodbit == 0); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp new file mode 100644 index 00000000000..238593feb30 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const openmode app; +// static const openmode ate; +// static const openmode binary; +// static const openmode in; +// static const openmode out; +// static const openmode trunc; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::app); + assert(std::ios_base::ate); + assert(std::ios_base::binary); + assert(std::ios_base::in); + assert(std::ios_base::out); + assert(std::ios_base::trunc); + + assert + ( + ( std::ios_base::app + & std::ios_base::ate + & std::ios_base::binary + & std::ios_base::in + & std::ios_base::out + & std::ios_base::trunc) == 0 + ); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp new file mode 100644 index 00000000000..005fb61cc31 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// static const seekdir beg; +// static const seekdir cur; +// static const seekdir end; + +#include <ios> +#include <cassert> + +int main() +{ + assert(std::ios_base::beg != std::ios_base::cur); + assert(std::ios_base::beg != std::ios_base::end); + assert(std::ios_base::cur != std::ios_base::end); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/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/libcxx/test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..760bfcb26d2 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +#include <ios> + +int main() +{ +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp new file mode 100644 index 00000000000..d86059ea6f7 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// explicit basic_ios(basic_streambuf<charT,traits>* sb); + +#include <ios> +#include <streambuf> +#include <cassert> + +int main() +{ + { + std::streambuf* sb = 0; + std::basic_ios<char> ios(sb); + assert(ios.rdbuf() == sb); + assert(ios.tie() == 0); + assert(ios.rdstate() == std::ios::badbit); + assert(ios.exceptions() == std::ios::goodbit); + assert(ios.flags() == (std::ios::skipws | std::ios::dec)); + assert(ios.width() == 0); + assert(ios.precision() == 6); + assert(ios.fill() == ' '); + assert(ios.getloc() == std::locale()); + } + { + std::streambuf* sb = (std::streambuf*)1; + std::basic_ios<char> ios(sb); + assert(ios.rdbuf() == sb); + assert(ios.tie() == 0); + assert(ios.rdstate() == std::ios::goodbit); + assert(ios.exceptions() == std::ios::goodbit); + assert(ios.flags() == (std::ios::skipws | std::ios::dec)); + assert(ios.width() == 0); + assert(ios.precision() == 6); + assert(ios.fill() == ' '); + assert(ios.getloc() == std::locale()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp new file mode 100644 index 00000000000..c46e2c054e8 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp @@ -0,0 +1,190 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_ios& copyfmt(const basic_ios& rhs); + +#include <ios> +#include <streambuf> +#include <cassert> + +#include "platform_support.h" // locale name macros + +struct testbuf + : public std::streambuf +{ +}; + +bool f1_called = false; +bool f2_called = false; + +bool g1_called = false; +bool g2_called = false; +bool g3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert( f2_called); + assert(!g1_called); + assert(!g2_called); + assert(!g3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 4); + f1_called = true; + } +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::erase_event) + { + assert(!f1_called); + assert(!f2_called); + assert(!g1_called); + assert(!g2_called); + assert(!g3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 5); + f2_called = true; + } +} + +void g1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::copyfmt_event) + { + assert( f1_called); + assert( f2_called); + assert(!g1_called); + assert( g2_called); + assert( g3_called); + assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8); + assert(index == 7); + g1_called = true; + } +} + +void g2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::copyfmt_event) + { + assert( f1_called); + assert( f2_called); + assert(!g1_called); + assert(!g2_called); + assert( g3_called); + assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8); + assert(index == 8); + g2_called = true; + } +} + +void g3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::copyfmt_event) + { + assert( f1_called); + assert( f2_called); + assert(!g1_called); + assert(!g2_called); + assert(!g3_called); + assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8); + assert(index == 9); + g3_called = true; + } +} + +int main() +{ + testbuf sb1; + std::ios ios1(&sb1); + ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed); + ios1.precision(1); + ios1.width(11); + ios1.imbue(std::locale(LOCALE_en_US_UTF_8)); + ios1.exceptions(std::ios::failbit); + ios1.setstate(std::ios::eofbit); + ios1.register_callback(f1, 4); + ios1.register_callback(f2, 5); + ios1.iword(0) = 1; + ios1.iword(1) = 2; + ios1.iword(2) = 3; + char c1, c2, c3; + ios1.pword(0) = &c1; + ios1.pword(1) = &c2; + ios1.pword(2) = &c3; + ios1.tie((std::ostream*)1); + ios1.fill('1'); + + testbuf sb2; + std::ios ios2(&sb2); + ios2.flags(std::ios::showpoint | std::ios::uppercase); + ios2.precision(2); + ios2.width(12); + ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8)); + ios2.exceptions(std::ios::eofbit); + ios2.setstate(std::ios::goodbit); + ios2.register_callback(g1, 7); + ios2.register_callback(g2, 8); + ios2.register_callback(g3, 9); + ios2.iword(0) = 4; + ios2.iword(1) = 5; + ios2.iword(2) = 6; + ios2.iword(3) = 7; + ios2.iword(4) = 8; + ios2.iword(5) = 9; + char d1, d2; + ios2.pword(0) = &d1; + ios2.pword(1) = &d2; + ios2.tie((std::ostream*)2); + ios2.fill('2'); + + ios1.copyfmt(ios1); + assert(!f1_called); + + try + { + ios1.copyfmt(ios2); + assert(false); + } + catch (std::ios_base::failure&) + { + } + assert(ios1.rdstate() == std::ios::eofbit); + assert(ios1.rdbuf() == &sb1); + assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase)); + assert(ios1.precision() == 2); + assert(ios1.width() == 12); + assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8); + assert(ios1.exceptions() == std::ios::eofbit); + assert(f1_called); + assert(f2_called); + assert(g1_called); + assert(g2_called); + assert(g3_called); + assert(ios1.iword(0) == 4); + assert(ios1.iword(1) == 5); + assert(ios1.iword(2) == 6); + assert(ios1.iword(3) == 7); + assert(ios1.iword(4) == 8); + assert(ios1.iword(5) == 9); + assert(ios1.pword(0) == &d1); + assert(ios1.pword(1) == &d2); + assert(ios1.tie() == (std::ostream*)2); + assert(ios1.fill() == '2'); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp new file mode 100644 index 00000000000..f5c5aa22b65 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char_type fill() const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::ios ios(0); + assert(ios.fill() == ' '); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp new file mode 100644 index 00000000000..10dccca8583 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char_type fill(char_type fillch); + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(ios.fill() == ' '); + char c = ios.fill('*'); + assert(c == ' '); + assert(ios.fill() == '*'); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp new file mode 100644 index 00000000000..6d4ce5f577f --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// locale imbue(const locale& loc); + +#include <ios> +#include <streambuf> +#include <cassert> + +#include "platform_support.h" // locale name macros + +struct testbuf + : public std::streambuf +{ +}; + +bool f1_called = false; +bool f2_called = false; +bool f3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert( f2_called); + assert( f3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 4); + f1_called = true; + } +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert(!f2_called); + assert( f3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 5); + f2_called = true; + } +} + +void f3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(!f1_called); + assert(!f2_called); + assert(!f3_called); + assert(stream.getloc().name() == LOCALE_en_US_UTF_8); + assert(index == 6); + f3_called = true; + } +} + +int main() +{ + { + std::ios ios(0); + ios.register_callback(f1, 4); + ios.register_callback(f2, 5); + ios.register_callback(f3, 6); + std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(l.name() == std::string("C")); + assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8)); + assert(f1_called); + assert(f2_called); + assert(f3_called); + } + f1_called = false; + f2_called = false; + f3_called = false; + { + testbuf sb; + std::ios ios(&sb); + ios.register_callback(f1, 4); + ios.register_callback(f2, 5); + ios.register_callback(f3, 6); + std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(l.name() == std::string("C")); + assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8)); + assert(sb.getloc().name() == std::string(LOCALE_en_US_UTF_8)); + assert(f1_called); + assert(f2_called); + assert(f3_called); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp new file mode 100644 index 00000000000..509b836686c --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// 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.fr_FR.UTF-8 + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void move(basic_ios&& rhs); + +#include <ios> +#include <streambuf> +#include <cassert> + +#include "platform_support.h" // locale name macros + +struct testbuf + : public std::streambuf +{ +}; + +struct testios + : public std::ios +{ + testios() {} + testios(std::streambuf* p) : std::ios(p) {} + void move(std::ios& x) {std::ios::move(x);} +}; + +bool f1_called = false; +bool f2_called = false; + +bool g1_called = false; +bool g2_called = false; +bool g3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + f1_called = true; +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + f2_called = true; +} + +void g1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(index == 7); + g1_called = true; + } +} + +void g2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(index == 8); + g2_called = true; + } +} + +void g3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + if (ev == std::ios_base::imbue_event) + { + assert(index == 9); + g3_called = true; + } +} + +int main() +{ + testios ios1; + testbuf sb2; + std::ios ios2(&sb2); + ios2.flags(std::ios::showpoint | std::ios::uppercase); + ios2.precision(2); + ios2.width(12); + ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8)); + ios2.exceptions(std::ios::eofbit); + ios2.setstate(std::ios::goodbit); + ios2.register_callback(g1, 7); + ios2.register_callback(g2, 8); + ios2.register_callback(g3, 9); + ios2.iword(0) = 4; + ios2.iword(1) = 5; + ios2.iword(2) = 6; + ios2.iword(3) = 7; + ios2.iword(4) = 8; + ios2.iword(5) = 9; + char d1, d2; + ios2.pword(0) = &d1; + ios2.pword(1) = &d2; + ios2.tie((std::ostream*)2); + ios2.fill('2'); + + ios1.move(ios2); + + assert(ios1.rdstate() == std::ios::goodbit); + assert(ios1.rdbuf() == 0); + assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase)); + assert(ios1.precision() == 2); + assert(ios1.width() == 12); + assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8); + assert(ios1.exceptions() == std::ios::eofbit); + assert(!f1_called); + assert(!f2_called); + assert(!g1_called); + assert(!g2_called); + assert(!g3_called); + assert(ios1.iword(0) == 4); + assert(ios1.iword(1) == 5); + assert(ios1.iword(2) == 6); + assert(ios1.iword(3) == 7); + assert(ios1.iword(4) == 8); + assert(ios1.iword(5) == 9); + assert(ios1.pword(0) == &d1); + assert(ios1.pword(1) == &d2); + assert(ios1.tie() == (std::ostream*)2); + assert(ios1.fill() == '2'); + ios1.imbue(std::locale("C")); + assert(!f1_called); + assert(!f2_called); + assert(g1_called); + assert(g2_called); + assert(g3_called); + + assert(ios2.rdbuf() == &sb2); + assert(ios2.tie() == 0); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp new file mode 100644 index 00000000000..bf865e68149 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char narrow(char_type c, char dfault) const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::ios ios(0); + assert(ios.narrow('c', '*') == 'c'); + assert(ios.narrow('\xFE', '*') == '*'); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp new file mode 100644 index 00000000000..7be92e72b86 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_streambuf<charT,traits>* rdbuf() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +int main() +{ + { + const std::ios ios(0); + assert(ios.rdbuf() == 0); + } + { + std::streambuf* sb = (std::streambuf*)1; + const std::ios ios(sb); + assert(ios.rdbuf() == sb); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp new file mode 100644 index 00000000000..cc0b3f3f169 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); + +#include <ios> +#include <streambuf> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(ios.rdbuf() == 0); + assert(!ios.good()); + std::streambuf* sb = (std::streambuf*)1; + std::streambuf* sb2 = ios.rdbuf(sb); + assert(sb2 == 0); + assert(ios.rdbuf() == sb); + assert(ios.good()); + sb2 = ios.rdbuf(0); + assert(sb2 == (std::streambuf*)1); + assert(ios.rdbuf() == 0); + assert(ios.bad()); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp new file mode 100644 index 00000000000..2d4beee37ec --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void set_rdbuf(basic_streambuf<charT, traits>* sb); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf + : public std::streambuf +{ +}; + +struct testios + : public std::ios +{ + testios(std::streambuf* p) : std::ios(p) {} + void set_rdbuf(std::streambuf* x) {std::ios::set_rdbuf(x);} +}; + +int main() +{ + testbuf sb1; + testbuf sb2; + testios ios(&sb1); + try + { + ios.setstate(std::ios::badbit); + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + ios.set_rdbuf(&sb2); + assert(ios.rdbuf() == &sb2); + try + { + ios.setstate(std::ios::badbit); + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + ios.set_rdbuf(0); + assert(ios.rdbuf() == 0); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp new file mode 100644 index 00000000000..e44f4b32512 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp @@ -0,0 +1,168 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void move(basic_ios&& rhs); + +#include <ios> +#include <streambuf> +#include <cassert> + +#include "platform_support.h" // locale name macros + +struct testbuf + : public std::streambuf +{ +}; + +struct testios + : public std::ios +{ + testios(std::streambuf* p) : std::ios(p) {} + void swap(std::ios& x) {std::ios::swap(x);} +}; + +bool f1_called = false; +bool f2_called = false; + +bool g1_called = false; +bool g2_called = false; +bool g3_called = false; + +void f1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + assert(index == 4); + f1_called = true; +} + +void f2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + assert(index == 5); + f2_called = true; +} + +void g1(std::ios_base::event ev, std::ios_base& stream, int index) +{ + assert(index == 7); + g1_called = true; +} + +void g2(std::ios_base::event ev, std::ios_base& stream, int index) +{ + assert(index == 8); + g2_called = true; +} + +void g3(std::ios_base::event ev, std::ios_base& stream, int index) +{ + assert(index == 9); + g3_called = true; +} + +int main() +{ + testbuf sb1; + testios ios1(&sb1); + ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed); + ios1.precision(1); + ios1.width(11); + ios1.imbue(std::locale(LOCALE_en_US_UTF_8)); + ios1.exceptions(std::ios::failbit); + ios1.setstate(std::ios::eofbit); + ios1.register_callback(f1, 4); + ios1.register_callback(f2, 5); + ios1.iword(0) = 1; + ios1.iword(1) = 2; + ios1.iword(2) = 3; + char c1, c2, c3; + ios1.pword(0) = &c1; + ios1.pword(1) = &c2; + ios1.pword(2) = &c3; + ios1.tie((std::ostream*)1); + ios1.fill('1'); + + testbuf sb2; + testios ios2(&sb2); + ios2.flags(std::ios::showpoint | std::ios::uppercase); + ios2.precision(2); + ios2.width(12); + ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8)); + ios2.exceptions(std::ios::eofbit); + ios2.setstate(std::ios::goodbit); + ios2.register_callback(g1, 7); + ios2.register_callback(g2, 8); + ios2.register_callback(g3, 9); + ios2.iword(0) = 4; + ios2.iword(1) = 5; + ios2.iword(2) = 6; + ios2.iword(3) = 7; + ios2.iword(4) = 8; + ios2.iword(5) = 9; + char d1, d2; + ios2.pword(0) = &d1; + ios2.pword(1) = &d2; + ios2.tie((std::ostream*)2); + ios2.fill('2'); + + ios1.swap(ios2); + + assert(ios1.rdstate() == std::ios::goodbit); + assert(ios1.rdbuf() == &sb1); + assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase)); + assert(ios1.precision() == 2); + assert(ios1.width() == 12); + assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8); + assert(ios1.exceptions() == std::ios::eofbit); + assert(!f1_called); + assert(!f2_called); + assert(!g1_called); + assert(!g2_called); + assert(!g3_called); + assert(ios1.iword(0) == 4); + assert(ios1.iword(1) == 5); + assert(ios1.iword(2) == 6); + assert(ios1.iword(3) == 7); + assert(ios1.iword(4) == 8); + assert(ios1.iword(5) == 9); + assert(ios1.pword(0) == &d1); + assert(ios1.pword(1) == &d2); + assert(ios1.tie() == (std::ostream*)2); + assert(ios1.fill() == '2'); + ios1.imbue(std::locale("C")); + assert(!f1_called); + assert(!f2_called); + assert(g1_called); + assert(g2_called); + assert(g3_called); + + assert(ios2.rdstate() == std::ios::eofbit); + assert(ios2.rdbuf() == &sb2); + assert(ios2.flags() == (std::ios::boolalpha | std::ios::dec | std::ios::fixed)); + assert(ios2.precision() == 1); + assert(ios2.width() == 11); + assert(ios2.getloc().name() == LOCALE_en_US_UTF_8); + assert(ios2.exceptions() == std::ios::failbit); + assert(ios2.iword(0) == 1); + assert(ios2.iword(1) == 2); + assert(ios2.iword(2) == 3); + assert(ios2.pword(0) == &c1); + assert(ios2.pword(1) == &c2); + assert(ios2.pword(2) == &c3); + assert(ios2.tie() == (std::ostream*)1); + assert(ios2.fill() == '1'); + ios2.imbue(std::locale("C")); + assert(f1_called); + assert(f2_called); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp new file mode 100644 index 00000000000..71eb238469c --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_ostream<charT,traits>* tie() const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::basic_ios<char> ios(0); + assert(ios.tie() == 0); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp new file mode 100644 index 00000000000..acccbea2aa0 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + std::ostream* os = (std::ostream*)1; + std::ostream* r = ios.tie(os); + assert(r == 0); + assert(ios.tie() == os); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp new file mode 100644 index 00000000000..68fdf685989 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// char_type widen(char c) const; + +#include <ios> +#include <cassert> + +int main() +{ + const std::ios ios(0); + assert(ios.widen('c') == 'c'); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp new file mode 100644 index 00000000000..1005df6ef25 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bad.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool bad() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(ios.bad()); + ios.setstate(std::ios::eofbit); + assert(ios.bad()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(!ios.bad()); + ios.setstate(std::ios::eofbit); + assert(!ios.bad()); + ios.setstate(std::ios::failbit); + assert(!ios.bad()); + ios.setstate(std::ios::badbit); + assert(ios.bad()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp new file mode 100644 index 00000000000..0de889e549c --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// operator unspecified-bool-type() const; + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(static_cast<bool>(ios) == !ios.fail()); + ios.setstate(std::ios::failbit); + assert(static_cast<bool>(ios) == !ios.fail()); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp new file mode 100644 index 00000000000..0c2e8f0860c --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void clear(iostate state = goodbit); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + ios.clear(); + assert(ios.rdstate() == std::ios::badbit); + try + { + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + try + { + ios.clear(); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == std::ios::badbit); + } + try + { + ios.clear(std::ios::eofbit); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); + } + } + { + testbuf sb; + std::ios ios(&sb); + ios.clear(); + assert(ios.rdstate() == std::ios::goodbit); + ios.exceptions(std::ios::badbit); + ios.clear(); + assert(ios.rdstate() == std::ios::goodbit); + ios.clear(std::ios::eofbit); + assert(ios.rdstate() == std::ios::eofbit); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp new file mode 100644 index 00000000000..64d5a3018d1 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool eof() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(!ios.eof()); + ios.setstate(std::ios::eofbit); + assert(ios.eof()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(!ios.eof()); + ios.setstate(std::ios::eofbit); + assert(ios.eof()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp new file mode 100644 index 00000000000..d5158a18468 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// iostate exceptions() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + const std::ios ios(0); + assert(ios.exceptions() == std::ios::goodbit); + } + { + testbuf sb; + const std::ios ios(&sb); + assert(ios.exceptions() == std::ios::goodbit); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp new file mode 100644 index 00000000000..a0013eabdac --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// iostate exceptions() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(ios.exceptions() == std::ios::goodbit); + ios.exceptions(std::ios::eofbit); + assert(ios.exceptions() == std::ios::eofbit); + try + { + ios.exceptions(std::ios::badbit); + assert(false); + } + catch (std::ios::failure&) + { + } + assert(ios.exceptions() == std::ios::badbit); + } + { + testbuf sb; + std::ios ios(&sb); + assert(ios.exceptions() == std::ios::goodbit); + ios.exceptions(std::ios::eofbit); + assert(ios.exceptions() == std::ios::eofbit); + ios.exceptions(std::ios::badbit); + assert(ios.exceptions() == std::ios::badbit); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp new file mode 100644 index 00000000000..fa9f765bfd5 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/fail.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool fail() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(ios.fail()); + ios.setstate(std::ios::eofbit); + assert(ios.fail()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(!ios.fail()); + ios.setstate(std::ios::eofbit); + assert(!ios.fail()); + ios.setstate(std::ios::badbit); + assert(ios.fail()); + ios.setstate(std::ios::failbit); + assert(ios.fail()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp new file mode 100644 index 00000000000..03f89506d6f --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/good.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool good() const; + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + assert(!ios.good()); + } + { + testbuf sb; + std::ios ios(&sb); + assert(ios.good()); + ios.setstate(std::ios::eofbit); + assert(!ios.good()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp new file mode 100644 index 00000000000..ef534f6d0ad --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// bool operator!() const; + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(!ios == ios.fail()); + ios.setstate(std::ios::failbit); + assert(!ios == ios.fail()); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp new file mode 100644 index 00000000000..d09e2a62ee3 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// iostate rdstate() const; + +#include <ios> +#include <cassert> + +int main() +{ + std::ios ios(0); + assert(ios.rdstate() == std::ios::badbit); + ios.setstate(std::ios::failbit); + assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp new file mode 100644 index 00000000000..b3c66c487e9 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits> class basic_ios + +// void setstate(iostate state); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + { + std::ios ios(0); + ios.setstate(std::ios::goodbit); + assert(ios.rdstate() == std::ios::badbit); + try + { + ios.exceptions(std::ios::badbit); + } + catch (...) + { + } + try + { + ios.setstate(std::ios::goodbit); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == std::ios::badbit); + } + try + { + ios.setstate(std::ios::eofbit); + assert(false); + } + catch (std::ios::failure&) + { + assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); + } + } + { + testbuf sb; + std::ios ios(&sb); + ios.setstate(std::ios::goodbit); + assert(ios.rdstate() == std::ios::goodbit); + ios.setstate(std::ios::eofbit); + assert(ios.rdstate() == std::ios::eofbit); + ios.setstate(std::ios::failbit); + assert(ios.rdstate() == (std::ios::eofbit | std::ios::failbit)); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/ios/types.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/types.pass.cpp new file mode 100644 index 00000000000..22e33f61f42 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios/types.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// template <class charT, class traits = char_traits<charT> > +// class basic_ios : public ios_base +// { +// public: +// typedef charT char_type; +// typedef typename traits::int_type int_type; +// typedef typename traits::pos_type pos_type; +// typedef typename traits::off_type off_type; +// typedef traits traits_type; + +#include <ios> +#include <type_traits> + +int main() +{ + static_assert((std::is_base_of<std::ios_base, std::basic_ios<char> >::value), ""); + static_assert((std::is_same<std::basic_ios<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::basic_ios<char>::traits_type, std::char_traits<char> >::value), ""); + static_assert((std::is_same<std::basic_ios<char>::int_type, std::char_traits<char>::int_type>::value), ""); + static_assert((std::is_same<std::basic_ios<char>::pos_type, std::char_traits<char>::pos_type>::value), ""); + static_assert((std::is_same<std::basic_ios<char>::off_type, std::char_traits<char>::off_type>::value), ""); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp new file mode 100644 index 00000000000..461c7774248 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& internal(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::internal(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::internal); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp new file mode 100644 index 00000000000..aa2ca6f27ef --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& left(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::left(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::left); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp new file mode 100644 index 00000000000..08056e8f353 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& right(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::right(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::right); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp new file mode 100644 index 00000000000..cbe03bceb2b --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& dec(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::dec(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::dec); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp new file mode 100644 index 00000000000..281a59cdafd --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& hex(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::hex(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::hex); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp new file mode 100644 index 00000000000..5ebfea86f4f --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& oct(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::oct(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::oct); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp new file mode 100644 index 00000000000..a93c7b4c2fe --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// const error_category& iostream_category(); + +#include <ios> +#include <cassert> +#include <string> + +int main() +{ + const std::error_category& e_cat1 = std::iostream_category(); + std::string m1 = e_cat1.name(); + assert(m1 == "iostream"); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp new file mode 100644 index 00000000000..f764fa6fd79 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// error_code make_error_code(io_errc e); + +#include <ios> +#include <cassert> + +int main() +{ + { + std::error_code ec = make_error_code(std::io_errc::stream); + assert(ec.value() == static_cast<int>(std::io_errc::stream)); + assert(ec.category() == std::iostream_category()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp new file mode 100644 index 00000000000..30931bae0bd --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// error_condition make_error_condition(io_errc e); + +#include <ios> +#include <cassert> + +int main() +{ + { + const std::error_condition ec1 = std::make_error_condition(std::io_errc::stream); + assert(ec1.value() == static_cast<int>(std::io_errc::stream)); + assert(ec1.category() == std::iostream_category()); + } +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp new file mode 100644 index 00000000000..f202bc4c881 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& defaultfloat(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::defaultfloat(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::fixed)); + assert(!(ios.flags() & std::ios::scientific)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp new file mode 100644 index 00000000000..55bf2648f3e --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& fixed(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::fixed(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::fixed); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp new file mode 100644 index 00000000000..2920cca83d0 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& hexfloat(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::hexfloat(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::fixed); + assert(ios.flags() & std::ios::scientific); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp new file mode 100644 index 00000000000..53cfd8171f3 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& scientific(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::scientific(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::scientific); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp new file mode 100644 index 00000000000..ca8cd93f05b --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& boolalpha(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::boolalpha(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::boolalpha); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp new file mode 100644 index 00000000000..ebc0aab67db --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noboolalpha(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::boolalpha(ios); + std::ios_base& r = std::noboolalpha(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::boolalpha)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp new file mode 100644 index 00000000000..91608f0f503 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noshowbase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::showbase(ios); + std::ios_base& r = std::noshowbase(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::showbase)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp new file mode 100644 index 00000000000..6e26416c5cd --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noshowpoint(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::showpoint(ios); + std::ios_base& r = std::noshowpoint(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::showpoint)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp new file mode 100644 index 00000000000..5e6911c22b9 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noshowpos(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::showpos(ios); + std::ios_base& r = std::noshowpos(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::showpos)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp new file mode 100644 index 00000000000..e78f5f884cc --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& noskipws(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::skipws(ios); + std::ios_base& r = std::noskipws(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::skipws)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp new file mode 100644 index 00000000000..5708038e5ed --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& nounitbuf(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::unitbuf(ios); + std::ios_base& r = std::nounitbuf(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::unitbuf)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp new file mode 100644 index 00000000000..76fac604b34 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& nouppercase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::uppercase(ios); + std::ios_base& r = std::nouppercase(ios); + assert(&r == &ios); + assert(!(ios.flags() & std::ios::uppercase)); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp new file mode 100644 index 00000000000..ddf3a855096 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& showbase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::showbase(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::showbase); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp new file mode 100644 index 00000000000..79ae3b6e27a --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& showpoint(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::showpoint(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::showpoint); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp new file mode 100644 index 00000000000..226542614c1 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& showpos(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::showpos(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::showpos); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp new file mode 100644 index 00000000000..4ea3e448fe0 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& skipws(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::skipws(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::skipws); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp new file mode 100644 index 00000000000..99a33c71c89 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& unitbuf(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::unitbuf(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::unitbuf); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp new file mode 100644 index 00000000000..1a19e2aa636 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// class ios_base + +// ios_base& uppercase(ios_base& str); + +#include <ios> +#include <streambuf> +#include <cassert> + +struct testbuf : public std::streambuf {}; + +int main() +{ + testbuf sb; + std::ios ios(&sb); + std::ios_base& r = std::uppercase(ios); + assert(&r == &ios); + assert(ios.flags() & std::ios::uppercase); +} diff --git a/libcxx/test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/std.ios.manip/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/libcxx/test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp b/libcxx/test/std/input.output/iostreams.base/stream.types/streamoff.pass.cpp new file mode 100644 index 00000000000..0e9f1278ee0 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/stream.types/streamoff.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// typedef OFF_T streamoff; + +#include <ios> +#include <type_traits> + +int main() +{ + static_assert(std::is_integral<std::streamoff>::value, ""); + static_assert(std::is_signed<std::streamoff>::value, ""); +} diff --git a/libcxx/test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp b/libcxx/test/std/input.output/iostreams.base/stream.types/streamsize.pass.cpp new file mode 100644 index 00000000000..438c51138ee --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/stream.types/streamsize.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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +// typedef SZ_T streamsize; + +#include <ios> +#include <type_traits> + +int main() +{ + static_assert(std::is_integral<std::streamsize>::value, ""); + static_assert(std::is_signed<std::streamsize>::value, ""); +} diff --git a/libcxx/test/std/input.output/iostreams.base/version.pass.cpp b/libcxx/test/std/input.output/iostreams.base/version.pass.cpp new file mode 100644 index 00000000000..f56846d38b8 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/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. +// +//===----------------------------------------------------------------------===// + +// <ios> + +#include <ios> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |