src/error.cpp
58.3% Lines (7/12)
100.0% List of functions (2/2)
42.9% Branches (6/14)
Functions (2)
Function
Calls
Lines
Branches
Blocks
boost::capy::detail::error_cat_type::name() const
:18
0
100.0%
–
–
boost::capy::detail::error_cat_type::message[abi:cxx11](int) const
:25
0
50.0%
42.9%
–
| Line | Branch | TLA | 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 | 1x | error_cat_type:: | ||
| 19 | name() const noexcept | |||
| 20 | { | |||
| 21 | 1x | return "boost.capy"; | ||
| 22 | } | |||
| 23 | ||||
| 24 | std::string | |||
| 25 | 1025x | error_cat_type:: | ||
| 26 | message(int code) const | |||
| 27 | { | |||
| 28 |
3/7✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1021 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
|
1025x | switch(static_cast<error>(code)) | |
| 29 | { | |||
| 30 |
1/1✓ Branch 1 taken 1 time.
|
3x | case error::eof: return "eof"; | |
| 31 | ✗ | case error::canceled: return "operation canceled"; | ||
| 32 |
1/1✓ Branch 1 taken 1021 times.
|
3063x | case error::test_failure: return "test failure"; | |
| 33 | ✗ | case error::stream_truncated: return "stream truncated"; | ||
| 34 | ✗ | case error::not_found: return "not found"; | ||
| 35 |
1/1✓ Branch 1 taken 3 times.
|
9x | case error::timeout: return "timeout"; | |
| 36 | ✗ | default: | ||
| 37 | ✗ | return "unknown"; | ||
| 38 | } | |||
| 39 | } | |||
| 40 | ||||
| 41 | //----------------------------------------------- | |||
| 42 | ||||
| 43 | // msvc 14.0 has a bug that warns about inability | |||
| 44 | // to use constexpr construction here, even though | |||
| 45 | // there's no constexpr construction | |||
| 46 | #if defined(_MSC_VER) && _MSC_VER <= 1900 | |||
| 47 | # pragma warning( push ) | |||
| 48 | # pragma warning( disable : 4592 ) | |||
| 49 | #endif | |||
| 50 | ||||
| 51 | #if defined(__cpp_constinit) && __cpp_constinit >= 201907L | |||
| 52 | constinit error_cat_type error_cat; | |||
| 53 | #else | |||
| 54 | error_cat_type error_cat; | |||
| 55 | #endif | |||
| 56 | ||||
| 57 | #if defined(_MSC_VER) && _MSC_VER <= 1900 | |||
| 58 | # pragma warning( pop ) | |||
| 59 | #endif | |||
| 60 | ||||
| 61 | } // detail | |||
| 62 | ||||
| 63 | } // capy | |||
| 64 | } // boost | |||
| 65 |