75.86% Lines (22/29)
100.00% Functions (3/3)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // | 3 | // | |||||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 6 | // | 6 | // | |||||
| 7 | // Official repository: https://github.com/cppalliance/capy | 7 | // Official repository: https://github.com/cppalliance/capy | |||||
| 8 | // | 8 | // | |||||
| 9 | 9 | |||||||
| 10 | #include <boost/capy/cond.hpp> | 10 | #include <boost/capy/cond.hpp> | |||||
| 11 | #include <boost/capy/error.hpp> | 11 | #include <boost/capy/error.hpp> | |||||
| 12 | #include <system_error> | 12 | #include <system_error> | |||||
| 13 | 13 | |||||||
| 14 | namespace boost { | 14 | namespace boost { | |||||
| 15 | namespace capy { | 15 | namespace capy { | |||||
| 16 | 16 | |||||||
| 17 | namespace detail { | 17 | namespace detail { | |||||
| 18 | 18 | |||||||
| 19 | const char* | 19 | const char* | |||||
| HITCBC | 20 | 1 | cond_cat_type:: | 20 | 1 | cond_cat_type:: | ||
| 21 | name() const noexcept | 21 | name() const noexcept | |||||
| 22 | { | 22 | { | |||||
| HITCBC | 23 | 1 | return "boost.capy"; | 23 | 1 | return "boost.capy"; | ||
| 24 | } | 24 | } | |||||
| 25 | 25 | |||||||
| 26 | std::string | 26 | std::string | |||||
| HITCBC | 27 | 4 | cond_cat_type:: | 27 | 4 | cond_cat_type:: | ||
| 28 | message(int code) const | 28 | message(int code) const | |||||
| 29 | { | 29 | { | |||||
| HITCBC | 30 | 4 | switch(static_cast<cond>(code)) | 30 | 4 | switch(static_cast<cond>(code)) | ||
| 31 | { | 31 | { | |||||
| HITCBC | 32 | 3 | case cond::eof: return "end of file"; | 32 | 3 | case cond::eof: return "end of file"; | ||
| HITCBC | 33 | 3 | case cond::canceled: return "operation canceled"; | 33 | 3 | case cond::canceled: return "operation canceled"; | ||
| MISUBC | 34 | ✗ | case cond::stream_truncated: return "stream truncated"; | 34 | ✗ | case cond::stream_truncated: return "stream truncated"; | ||
| HITCBC | 35 | 3 | case cond::not_found: return "not found"; | 35 | 3 | case cond::not_found: return "not found"; | ||
| HITCBC | 36 | 3 | case cond::timeout: return "operation timed out"; | 36 | 3 | case cond::timeout: return "operation timed out"; | ||
| MISUBC | 37 | ✗ | default: | 37 | ✗ | default: | ||
| MISUBC | 38 | ✗ | return "unknown"; | 38 | ✗ | return "unknown"; | ||
| 39 | } | 39 | } | |||||
| 40 | } | 40 | } | |||||
| 41 | 41 | |||||||
| 42 | bool | 42 | bool | |||||
| HITCBC | 43 | 1381 | cond_cat_type:: | 43 | 1381 | cond_cat_type:: | ||
| 44 | equivalent( | 44 | equivalent( | |||||
| 45 | std::error_code const& ec, | 45 | std::error_code const& ec, | |||||
| 46 | int condition) const noexcept | 46 | int condition) const noexcept | |||||
| 47 | { | 47 | { | |||||
| HITCBC | 48 | 1381 | switch(static_cast<cond>(condition)) | 48 | 1381 | switch(static_cast<cond>(condition)) | ||
| 49 | { | 49 | { | |||||
| HITCBC | 50 | 1357 | case cond::eof: | 50 | 1357 | case cond::eof: | ||
| HITCBC | 51 | 1357 | return ec == capy::error::eof; | 51 | 1357 | return ec == capy::error::eof; | ||
| 52 | 52 | |||||||
| HITCBC | 53 | 8 | case cond::canceled: | 53 | 8 | case cond::canceled: | ||
| HITCBC | 54 | 8 | if(ec == capy::error::canceled) | 54 | 8 | if(ec == capy::error::canceled) | ||
| HITCBC | 55 | 2 | return true; | 55 | 2 | return true; | ||
| HITCBC | 56 | 6 | if(ec == std::errc::operation_canceled) | 56 | 6 | if(ec == std::errc::operation_canceled) | ||
| HITCBC | 57 | 2 | return true; | 57 | 2 | return true; | ||
| HITCBC | 58 | 4 | return false; | 58 | 4 | return false; | ||
| 59 | 59 | |||||||
| MISUBC | 60 | ✗ | case cond::stream_truncated: | 60 | ✗ | case cond::stream_truncated: | ||
| MISUBC | 61 | ✗ | return ec == capy::error::stream_truncated; | 61 | ✗ | return ec == capy::error::stream_truncated; | ||
| 62 | 62 | |||||||
| HITCBC | 63 | 14 | case cond::not_found: | 63 | 14 | case cond::not_found: | ||
| HITCBC | 64 | 14 | return ec == capy::error::not_found; | 64 | 14 | return ec == capy::error::not_found; | ||
| 65 | 65 | |||||||
| HITCBC | 66 | 2 | case cond::timeout: | 66 | 2 | case cond::timeout: | ||
| HITCBC | 67 | 2 | return ec == capy::error::timeout; | 67 | 2 | return ec == capy::error::timeout; | ||
| 68 | 68 | |||||||
| MISUBC | 69 | ✗ | default: | 69 | ✗ | default: | ||
| MISUBC | 70 | ✗ | return false; | 70 | ✗ | return false; | ||
| 71 | } | 71 | } | |||||
| 72 | } | 72 | } | |||||
| 73 | 73 | |||||||
| 74 | //----------------------------------------------- | 74 | //----------------------------------------------- | |||||
| 75 | 75 | |||||||
| 76 | // msvc 14.0 has a bug that warns about inability | 76 | // msvc 14.0 has a bug that warns about inability | |||||
| 77 | // to use constexpr construction here, even though | 77 | // to use constexpr construction here, even though | |||||
| 78 | // there's no constexpr construction | 78 | // there's no constexpr construction | |||||
| 79 | #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900) | 79 | #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900) | |||||
| 80 | BOOST_CAPY_MSVC_WARNING_PUSH | 80 | BOOST_CAPY_MSVC_WARNING_PUSH | |||||
| 81 | BOOST_CAPY_MSVC_WARNING_DISABLE(4592) | 81 | BOOST_CAPY_MSVC_WARNING_DISABLE(4592) | |||||
| 82 | #endif | 82 | #endif | |||||
| 83 | 83 | |||||||
| 84 | #if defined(__cpp_constinit) && __cpp_constinit >= 201907L | 84 | #if defined(__cpp_constinit) && __cpp_constinit >= 201907L | |||||
| 85 | constinit cond_cat_type cond_cat; | 85 | constinit cond_cat_type cond_cat; | |||||
| 86 | #else | 86 | #else | |||||
| 87 | cond_cat_type cond_cat; | 87 | cond_cat_type cond_cat; | |||||
| 88 | #endif | 88 | #endif | |||||
| 89 | 89 | |||||||
| 90 | #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900) | 90 | #if BOOST_CAPY_WORKAROUND(_MSC_VER, <= 1900) | |||||
| 91 | BOOST_CAPY_MSVC_WARNING_POP | 91 | BOOST_CAPY_MSVC_WARNING_POP | |||||
| 92 | #endif | 92 | #endif | |||||
| 93 | 93 | |||||||
| 94 | } // detail | 94 | } // detail | |||||
| 95 | 95 | |||||||
| 96 | } // capy | 96 | } // capy | |||||
| 97 | } // boost | 97 | } // boost | |||||