libs/capy/src/error.cpp
27.3% Lines (3/11)
50.0% Functions (1/2)
16.7% Branches (2/12)
libs/capy/src/error.cpp
| Line | Branch | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // | ||
| 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) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/cppalliance/capy | ||
| 8 | // | ||
| 9 | |||
| 10 | #include <boost/capy/error.hpp> | ||
| 11 | |||
| 12 | namespace boost { | ||
| 13 | namespace capy { | ||
| 14 | |||
| 15 | namespace detail { | ||
| 16 | |||
| 17 | const char* | ||
| 18 | ✗ | error_cat_type:: | |
| 19 | name() const noexcept | ||
| 20 | { | ||
| 21 | ✗ | return "boost.capy"; | |
| 22 | } | ||
| 23 | |||
| 24 | std::string | ||
| 25 | 620 | error_cat_type:: | |
| 26 | message(int code) const | ||
| 27 | { | ||
| 28 |
1/6✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
620 | switch(static_cast<error>(code)) |
| 29 | { | ||
| 30 | ✗ | case error::eof: return "eof"; | |
| 31 | ✗ | case error::canceled: return "operation canceled"; | |
| 32 |
1/1✓ Branch 1 taken 620 times.
|
1860 | case error::test_failure: return "test failure"; |
| 33 | ✗ | case error::stream_truncated: return "stream truncated"; | |
| 34 | ✗ | case error::not_found: return "not found"; | |
| 35 | ✗ | default: | |
| 36 | ✗ | return "unknown"; | |
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | //----------------------------------------------- | ||
| 41 | |||
| 42 | // msvc 14.0 has a bug that warns about inability | ||
| 43 | // to use constexpr construction here, even though | ||
| 44 | // there's no constexpr construction | ||
| 45 | #if defined(_MSC_VER) && _MSC_VER <= 1900 | ||
| 46 | # pragma warning( push ) | ||
| 47 | # pragma warning( disable : 4592 ) | ||
| 48 | #endif | ||
| 49 | |||
| 50 | #if defined(__cpp_constinit) && __cpp_constinit >= 201907L | ||
| 51 | constinit error_cat_type error_cat; | ||
| 52 | #else | ||
| 53 | error_cat_type error_cat; | ||
| 54 | #endif | ||
| 55 | |||
| 56 | #if defined(_MSC_VER) && _MSC_VER <= 1900 | ||
| 57 | # pragma warning( pop ) | ||
| 58 | #endif | ||
| 59 | |||
| 60 | } // detail | ||
| 61 | |||
| 62 | } // capy | ||
| 63 | } // boost | ||
| 64 |