summaryrefslogtreecommitdiff
path: root/test/std/diagnostics/syserr/syserr.errcode
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/diagnostics/syserr/syserr.errcode')
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp12
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp44
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp45
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp33
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp27
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp26
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp27
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp30
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp23
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp31
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp24
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp23
-rw-r--r--test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp12
16 files changed, 442 insertions, 0 deletions
diff --git a/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
new file mode 100644
index 0000000000000..0100b1c77724e
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+ zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+ return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+ {
+ std::error_code ec(two);
+ assert(ec.value() == 2);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
new file mode 100644
index 0000000000000..569681b751e8a
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ std::error_code ec;
+ assert(ec.value() == 0);
+ assert(ec.category() == std::system_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
new file mode 100644
index 0000000000000..56489bb71b17f
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ }
+ {
+ std::error_code ec(8, std::generic_category());
+ assert(ec.value() == 8);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
new file mode 100644
index 0000000000000..6c073c9fd151d
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+ zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+ return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+ {
+ std::error_code ec;
+ ec = two;
+ assert(ec.value() == 2);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
new file mode 100644
index 0000000000000..967692a4f1dc4
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec;
+ ec.assign(6, std::system_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::system_category());
+ }
+ {
+ std::error_code ec;
+ ec.assign(8, std::generic_category());
+ assert(ec.value() == 8);
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
new file mode 100644
index 0000000000000..83faa03d28fa7
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec;
+ ec.assign(6, std::generic_category());
+ assert(ec.value() == 6);
+ assert(ec.category() == std::generic_category());
+ ec.clear();
+ assert(ec.value() == 0);
+ assert(ec.category() == std::system_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
new file mode 100644
index 0000000000000..01abc42b3ea96
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// bool operator<(const error_code& lhs, const error_code& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_code ec1(6, std::generic_category());
+ const std::error_code ec2(7, std::generic_category());
+ assert(ec1 < ec2);
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp
new file mode 100644
index 0000000000000..fc4e0f2b25eb9
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code make_error_code(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ std::error_code ec = make_error_code(std::errc::operation_canceled);
+ assert(ec.value() == static_cast<int>(std::errc::operation_canceled));
+ assert(ec.category() == std::generic_category());
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
new file mode 100644
index 0000000000000..09c87e5cea1cb
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <class charT, class traits>
+// basic_ostream<charT,traits>&
+// operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
+
+#include <system_error>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream out;
+ out << std::error_code(std::io_errc::stream);
+ assert(out.str() == "iostream:1");
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
new file mode 100644
index 0000000000000..0b20024013fc4
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_code ec(6, std::generic_category());
+ assert(static_cast<bool>(ec));
+ }
+ {
+ const std::error_code ec(0, std::generic_category());
+ assert(!static_cast<bool>(ec));
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
new file mode 100644
index 0000000000000..f2e50cf65ce14
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_code ec(6, std::generic_category());
+ assert(ec.category() == std::generic_category());
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
new file mode 100644
index 0000000000000..0a67cd5db6ad7
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_condition default_error_condition() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::error_code ec(6, std::generic_category());
+ std::error_condition e_cond = ec.default_error_condition();
+ assert(e_cond == ec);
+ }
+ {
+ const std::error_code ec(6, std::system_category());
+ std::error_condition e_cond = ec.default_error_condition();
+ assert(e_cond == ec);
+ }
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
new file mode 100644
index 0000000000000..530f42ca9b891
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ const std::error_code ec(6, std::generic_category());
+ assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
new file mode 100644
index 0000000000000..1047b7d4213e1
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+ const std::error_code ec(6, std::system_category());
+ assert(ec.value() == 6);
+}
diff --git a/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/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()
+{
+}