Skip to content

Commit 1633044

Browse files
committed
Fix linking-tests.cpp.
1 parent 7c62982 commit 1633044

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

examples/src/linking-tests.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <cstdint>
44
#include <exception>
55
#include <iostream>
6-
#include <string_view>
6+
#include <string>
7+
#include <system_error>
78

89
#include <ystdlib/containers/Array.hpp>
910
#include <ystdlib/error_handling/ErrorCode.hpp>
@@ -17,18 +18,28 @@ enum class BinaryErrorCodeEnum : uint8_t {
1718
};
1819

1920
using BinaryErrorCode = ystdlib::error_handling::ErrorCode<BinaryErrorCodeEnum>;
20-
2121
using BinaryErrorCategory = ystdlib::error_handling::ErrorCategory<BinaryErrorCodeEnum>;
2222

23-
constexpr std::string_view cBinaryTestErrorCategoryName{"Binary Error Code"};
24-
2523
template <>
2624
auto BinaryErrorCategory::name() const noexcept -> char const* {
27-
return cBinaryTestErrorCategoryName.data();
25+
return "Binary Error Code";
26+
}
27+
28+
template <>
29+
auto BinaryErrorCategory::message(BinaryErrorCodeEnum error_enum) const -> std::string {
30+
switch (error_enum) {
31+
case BinaryErrorCodeEnum::Success:
32+
return std::string{"Success"};
33+
case BinaryErrorCodeEnum::Failure:
34+
return std::string{"Failure"};
35+
default:
36+
return std::string{"Unrecognized Error Code"};
37+
}
2838
}
2939

3040
YSTDLIB_ERROR_HANDLING_MARK_AS_ERROR_CODE_ENUM(BinaryErrorCodeEnum);
3141

42+
namespace {
3243
using ystdlib::io_interface::ErrorCode;
3344

3445
class FailureReader : ystdlib::io_interface::ReaderInterface {
@@ -51,16 +62,15 @@ class FailureReader : ystdlib::io_interface::ReaderInterface {
5162
}
5263
};
5364

54-
namespace {
5565
auto test_containers() -> bool {
5666
try {
5767
constexpr size_t cBufferSize{1024};
5868
ystdlib::containers::Array<size_t> arr(cBufferSize);
59-
for (size_t idx{0}; idx < cBufferSize; ++idx) {
60-
arr.at(idx) = idx;
61-
}
62-
auto const& arr_const_ref = arr;
63-
return std::ranges::equal(arr, arr_const_ref);
69+
for (size_t idx{0}; idx < cBufferSize; ++idx) {
70+
arr.at(idx) = idx;
71+
}
72+
auto const& arr_const_ref = arr;
73+
return std::ranges::equal(arr, arr_const_ref);
6474
} catch (std::exception const&) {
6575
return false;
6676
}
@@ -83,7 +93,7 @@ auto test_wrapped_facade_headers() -> bool {
8393
quad_t const quadt{3};
8494
return 1 == uint && 2 == ulong && 3 == quadt;
8595
}
86-
}
96+
} // namespace
8797

8898
auto main() -> int {
8999
if (false == test_containers()) {

0 commit comments

Comments
 (0)