diff options
Diffstat (limited to 'libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers')
5 files changed, 131 insertions, 0 deletions
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp new file mode 100644 index 00000000000..0b20024013f --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp new file mode 100644 index 00000000000..f2e50cf65ce --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp new file mode 100644 index 00000000000..0a67cd5db6a --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp new file mode 100644 index 00000000000..530f42ca9b8 --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp new file mode 100644 index 00000000000..1047b7d4213 --- /dev/null +++ b/libcxx/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); +} |