diff options
Diffstat (limited to 'libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers')
4 files changed, 100 insertions, 0 deletions
diff --git a/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp new file mode 100644 index 00000000000..44257639721 --- /dev/null +++ b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_condition + +// explicit operator bool() const; + +#include <system_error> +#include <string> +#include <cassert> + +int main() +{ + { + const std::error_condition ec(6, std::generic_category()); + assert(static_cast<bool>(ec)); + } + { + const std::error_condition ec(0, std::generic_category()); + assert(!static_cast<bool>(ec)); + } +} diff --git a/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp new file mode 100644 index 00000000000..7b7d6788e38 --- /dev/null +++ b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_condition + +// const error_category& category() const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_condition ec(6, std::generic_category()); + assert(ec.category() == std::generic_category()); +} diff --git a/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp new file mode 100644 index 00000000000..4e9e61eaf38 --- /dev/null +++ b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_condition + +// string message() const; + +#include <system_error> +#include <string> +#include <cassert> + +int main() +{ + const std::error_condition ec(6, std::generic_category()); + assert(ec.message() == std::generic_category().message(6)); +} diff --git a/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp new file mode 100644 index 00000000000..5dcc4227011 --- /dev/null +++ b/libcxx/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_condition + +// int value() const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_condition ec(6, std::system_category()); + assert(ec.value() == 6); +} |