diff options
Diffstat (limited to 'test/std/input.output/iostreams.base/ios')
26 files changed, 1386 insertions, 0 deletions
diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp new file mode 100644 index 0000000000000..d86059ea6f7dd --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp new file mode 100644 index 0000000000000..c46e2c054e8f8 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp new file mode 100644 index 0000000000000..f5c5aa22b65bb --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp new file mode 100644 index 0000000000000..10dccca8583e5 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp new file mode 100644 index 0000000000000..6d4ce5f577f48 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp new file mode 100644 index 0000000000000..509b836686c53 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp new file mode 100644 index 0000000000000..bf865e68149d4 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp new file mode 100644 index 0000000000000..7be92e72b8699 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp new file mode 100644 index 0000000000000..cc0b3f3f169b1 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp new file mode 100644 index 0000000000000..2d4beee37ec20 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp new file mode 100644 index 0000000000000..e44f4b32512c2 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp new file mode 100644 index 0000000000000..71eb238469c9d --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp new file mode 100644 index 0000000000000..acccbea2aa069 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp new file mode 100644 index 0000000000000..68fdf68598993 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp new file mode 100644 index 0000000000000..1005df6ef258d --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp new file mode 100644 index 0000000000000..0de889e549cc9 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp new file mode 100644 index 0000000000000..0c2e8f0860cef --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp new file mode 100644 index 0000000000000..64d5a3018d15e --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp new file mode 100644 index 0000000000000..d5158a1846833 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp new file mode 100644 index 0000000000000..a0013eabdac63 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp new file mode 100644 index 0000000000000..fa9f765bfd59e --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp new file mode 100644 index 0000000000000..03f89506d6fdb --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp new file mode 100644 index 0000000000000..ef534f6d0adf1 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp new file mode 100644 index 0000000000000..d09e2a62ee3d7 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp new file mode 100644 index 0000000000000..b3c66c487e9f9 --- /dev/null +++ b/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/test/std/input.output/iostreams.base/ios/types.pass.cpp b/test/std/input.output/iostreams.base/ios/types.pass.cpp new file mode 100644 index 0000000000000..22e33f61f428e --- /dev/null +++ b/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), ""); +} |