summaryrefslogtreecommitdiff
path: root/test/std/input.output/iostreams.base/ios/iostate.flags
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 18:46:46 +0000
commit61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch)
treeec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/input.output/iostreams.base/ios/iostate.flags
parentf857581820d15e410e9945d2fcd5f7163be25a96 (diff)
Notes
Diffstat (limited to 'test/std/input.output/iostreams.base/ios/iostate.flags')
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp41
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp65
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp37
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp33
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp48
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp41
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp35
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp25
-rw-r--r--test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp64
11 files changed, 439 insertions, 0 deletions
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 000000000000..1005df6ef258
--- /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 000000000000..0de889e549cc
--- /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 000000000000..0c2e8f0860ce
--- /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 000000000000..64d5a3018d15
--- /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 000000000000..d5158a184683
--- /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 000000000000..a0013eabdac6
--- /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 000000000000..fa9f765bfd59
--- /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 000000000000..03f89506d6fd
--- /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 000000000000..ef534f6d0adf
--- /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 000000000000..d09e2a62ee3d
--- /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 000000000000..b3c66c487e9f
--- /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));
+ }
+}