libs/http/src/bcrypt/error.cpp

54.5% Lines (6/11) 66.7% Functions (2/3) 60.0% Branches (3/5)
libs/http/src/bcrypt/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/http
8 //
9
10 #include <boost/http/bcrypt/error.hpp>
11
12 namespace boost {
13 namespace http {
14 namespace bcrypt {
15 namespace detail {
16
17 const char*
18 error_cat_type::
19 name() const noexcept
20 {
21 return "boost.http.bcrypt";
22 }
23
24 std::string
25 2 error_cat_type::
26 message(int ev) const
27 {
28
1/1
✓ Branch 2 taken 2 times.
4 return message(ev, nullptr, 0);
29 }
30
31 char const*
32 2 error_cat_type::
33 message(
34 int ev,
35 char*,
36 std::size_t) const noexcept
37 {
38
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
2 switch(static_cast<error>(ev))
39 {
40 case error::ok: return "success";
41 1 case error::invalid_salt: return "invalid salt";
42 1 case error::invalid_hash: return "invalid hash";
43 default:
44 return "unknown";
45 }
46 }
47
48 #if defined(__cpp_constinit) && __cpp_constinit >= 201907L
49 constinit error_cat_type error_cat;
50 #else
51 error_cat_type error_cat;
52 #endif
53
54 } // detail
55 } // bcrypt
56 } // http
57 } // boost
58