diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
commit | 51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch) | |
tree | 91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/std/diagnostics/syserr | |
parent | bb5e33f003797b67974a8893f7f2930fc51b8210 (diff) |
Notes
Diffstat (limited to 'test/std/diagnostics/syserr')
5 files changed, 35 insertions, 30 deletions
diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp index 0573ef862efd..f6a97ef92d84 100644 --- a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 // <system_error> // class error_category @@ -18,23 +19,17 @@ #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();} + virtual std::string message(int) 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/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp index 972299936ddf..65ecc4921212 100644 --- a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp @@ -16,10 +16,24 @@ #include <system_error> #include <cassert> #include <string> +#include <cerrno> + +#include "test_macros.h" + +void test_message_for_bad_value() { + errno = E2BIG; // something that message will never generate + const std::error_category& e_cat1 = std::generic_category(); + const std::string msg = e_cat1.message(-1); + LIBCPP_ASSERT(msg == "Unknown error -1"); + assert(errno == E2BIG); +} int main() { const std::error_category& e_cat1 = std::generic_category(); std::string m1 = e_cat1.name(); assert(m1 == "generic"); + { + test_message_for_bad_value(); + } } diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp index b5cb18ad7653..d1a94883f925 100644 --- a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp @@ -16,6 +16,17 @@ #include <system_error> #include <cassert> #include <string> +#include <cerrno> + +#include "test_macros.h" + +void test_message_for_bad_value() { + errno = E2BIG; // something that message will never generate + const std::error_category& e_cat1 = std::system_category(); + const std::string msg = e_cat1.message(-1); + LIBCPP_ASSERT(msg == "Unknown error -1"); + assert(errno == E2BIG); +} int main() { @@ -26,4 +37,7 @@ int main() e_cond = e_cat1.default_error_condition(5000); assert(e_cond.value() == 5000); assert(e_cond.category() == std::system_category()); + { + test_message_for_bad_value(); + } } diff --git a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp index b812e364bbc5..c8b3d98103c4 100644 --- a/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp @@ -16,12 +16,12 @@ // size_t operator()(T val) const; // }; -// Not very portable - #include <system_error> #include <cassert> #include <type_traits> +#include "test_macros.h" + void test(int i) { @@ -31,7 +31,9 @@ test(int i) static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); H h; T ec(i, std::system_category()); - assert(h(ec) == i); + const std::size_t result = h(ec); + LIBCPP_ASSERT(result == i); + ((void)result); // Prevent unused warning } int main() diff --git a/test/std/diagnostics/syserr/version.pass.cpp b/test/std/diagnostics/syserr/version.pass.cpp deleted file mode 100644 index 3851150fdf90..000000000000 --- a/test/std/diagnostics/syserr/version.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -#include <system_error> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} |