diff options
Diffstat (limited to 'libcxx/test/std/diagnostics/syserr/syserr.errcat')
12 files changed, 311 insertions, 0 deletions
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/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.errcat/syserr.errcat.derived/message.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp new file mode 100644 index 00000000000..82770fb438b --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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_category + +// virtual string message(int ev) const = 0; + +#include <system_error> +#include <cassert> +#include <string> + +#include <stdio.h> + +int main() +{ + const std::error_category& e_cat1 = std::generic_category(); + const std::error_category& e_cat2 = std::system_category(); + std::string m1 = e_cat1.message(5); + std::string m2 = e_cat2.message(5); + std::string m3 = e_cat2.message(6); + assert(!m1.empty()); + assert(!m2.empty()); + assert(!m3.empty()); + assert(m1 == m2); + assert(m1 != m3); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp new file mode 100644 index 00000000000..0573ef862ef --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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_category + +// constexpr error_category() noexcept; + +#include <system_error> +#include <type_traits> +#include <string> +#include <cassert> + +#if _LIBCPP_STD_VER > 11 + +class test1 + : public std::error_category +{ +public: + constexpr test1() = default; // won't compile if error_category() is not constexpr + virtual const char* name() const noexcept {return nullptr;} + virtual std::string message(int ev) const {return std::string();} +}; + +#endif // _LIBCPP_STD_VER > 11 + +int main() +{ +#if _LIBCPP_STD_VER > 11 + static_assert(std::is_nothrow_default_constructible<test1>::value, + "error_category() must exist and be noexcept"); +#endif // _LIBCPP_STD_VER > 11 +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp new file mode 100644 index 00000000000..bec5e630aec --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.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_category + +// bool operator==(const error_category& rhs) const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_category& e_cat1 = std::generic_category(); + const std::error_category& e_cat2 = std::generic_category(); + const std::error_category& e_cat3 = std::system_category(); + assert(e_cat1 == e_cat2); + assert(!(e_cat1 == e_cat3)); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp new file mode 100644 index 00000000000..707604e486a --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.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_category + +// bool operator<(const error_category& rhs) const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_category& e_cat1 = std::generic_category(); + const std::error_category& e_cat2 = std::generic_category(); + const std::error_category& e_cat3 = std::system_category(); + assert(!(e_cat1 < e_cat2) && !(e_cat2 < e_cat1)); + assert((e_cat1 < e_cat3) || (e_cat3 < e_cat1)); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp new file mode 100644 index 00000000000..e74458f3fbb --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.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_category + +// bool operator!=(const error_category& rhs) const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_category& e_cat1 = std::generic_category(); + const std::error_category& e_cat2 = std::generic_category(); + const std::error_category& e_cat3 = std::system_category(); + assert(!(e_cat1 != e_cat2)); + assert(e_cat1 != e_cat3); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp new file mode 100644 index 00000000000..972299936dd --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.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. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_category + +// const error_category& generic_category(); + +#include <system_error> +#include <cassert> +#include <string> + +int main() +{ + const std::error_category& e_cat1 = std::generic_category(); + std::string m1 = e_cat1.name(); + assert(m1 == "generic"); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp new file mode 100644 index 00000000000..b5cb18ad765 --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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_category + +// const error_category& system_category(); + +#include <system_error> +#include <cassert> +#include <string> + +int main() +{ + const std::error_category& e_cat1 = std::system_category(); + std::error_condition e_cond = e_cat1.default_error_condition(5); + assert(e_cond.value() == 5); + assert(e_cond.category() == std::generic_category()); + e_cond = e_cat1.default_error_condition(5000); + assert(e_cond.value() == 5000); + assert(e_cond.category() == std::system_category()); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp new file mode 100644 index 00000000000..23530587839 --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// 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_category + +#include <system_error> + +int main() +{ + std::error_category* p = 0; +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp new file mode 100644 index 00000000000..dd51827128b --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.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. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_category + +// virtual error_condition default_error_condition(int ev) const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_category& e_cat = std::generic_category(); + std::error_condition e_cond = e_cat.default_error_condition(static_cast<int>(std::errc::not_a_directory)); + assert(e_cond.category() == e_cat); + assert(e_cond.value() == static_cast<int>(std::errc::not_a_directory)); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp new file mode 100644 index 00000000000..d26541d943f --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.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_category + +// virtual bool equivalent(const error_code& code, int condition) const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_category& e_cat = std::generic_category(); + assert(e_cat.equivalent(std::error_code(5, e_cat), 5)); + assert(!e_cat.equivalent(std::error_code(5, e_cat), 6)); +} diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp new file mode 100644 index 00000000000..d7cf844dffe --- /dev/null +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.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. +// +//===----------------------------------------------------------------------===// + +// <system_error> + +// class error_category + +// virtual bool equivalent(int code, const error_condition& condition) const; + +#include <system_error> +#include <cassert> + +int main() +{ + const std::error_category& e_cat = std::generic_category(); + std::error_condition e_cond = e_cat.default_error_condition(5); + assert(e_cat.equivalent(5, e_cond)); + assert(!e_cat.equivalent(6, e_cond)); +} |