diff options
| author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
| commit | 5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch) | |
| tree | afde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/diagnostics/syserr/syserr.errcode | |
| parent | f11e8eab527fba316c64112f6e05de1a79693a3e (diff) | |
| download | bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip | |
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/diagnostics/syserr/syserr.errcode')
16 files changed, 442 insertions, 0 deletions
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp new file mode 100644 index 00000000000..0100b1c7772 --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp new file mode 100644 index 00000000000..569681b751e --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp new file mode 100644 index 00000000000..56489bb71b1 --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp new file mode 100644 index 00000000000..6c073c9fd15 --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp new file mode 100644 index 00000000000..967692a4f1d --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp new file mode 100644 index 00000000000..83faa03d28f --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp new file mode 100644 index 00000000000..01abc42b3ea --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp new file mode 100644 index 00000000000..fc4e0f2b25e --- /dev/null +++ b/libcxx/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/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp new file mode 100644 index 00000000000..09c87e5cea1 --- /dev/null +++ b/libcxx/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/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); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/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() +{ +} |

