Skip to content

Commit 6e7ac3d

Browse files
committed
Redo test file naming and namespace conventions
1 parent 88a4c3e commit 6e7ac3d

File tree

6 files changed

+69
-37
lines changed

6 files changed

+69
-37
lines changed

src/ystdlib/error_handling/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ cpp_library(
22
NAME error_handling
33
NAMESPACE ystdlib
44
TESTS_SOURCES
5-
test-Defs.hpp
6-
test-Defs.cpp
5+
test-constants.hpp
6+
test-types.hpp
7+
test-types.cpp
78
test-ErrorCode.cpp
89
)

src/ystdlib/error_handling/test-Defs.hpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/ystdlib/error_handling/test-ErrorCode.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
#include <catch2/catch_test_macros.hpp>
99

10-
#include "test-Defs.hpp"
10+
#include "test-constants.hpp"
11+
#include "test-types.hpp"
1112

13+
namespace ystdlib::error_handling::test {
1214
TEST_CASE("test_error_code", "[error_handling][ErrorCode]") {
1315
// Test error codes within the same error category
1416
BinaryErrorCode const success{BinaryErrorCodeEnum::Success};
@@ -61,3 +63,4 @@ TEST_CASE("test_error_code_failure_condition", "[error_handling][ErrorCode]") {
6163
}
6264
);
6365
}
66+
} // namespace ystdlib::error_handling::test
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef YSTDLIB_ERROR_HANDLING_TEST_CONSTANTS_HPP
2+
#define YSTDLIB_ERROR_HANDLING_TEST_CONSTANTS_HPP
3+
4+
#include <array>
5+
#include <string_view>
6+
#include <system_error>
7+
8+
namespace ystdlib::error_handling::test {
9+
constexpr std::string_view cAlwaysSuccessErrorCategoryName{"Always Success Error Code"};
10+
constexpr std::string_view cBinaryTestErrorCategoryName{"Binary Error Code"};
11+
constexpr std::string_view cSuccessErrorMsg{"Success"};
12+
constexpr std::string_view cFailureErrorMsg{"Failure"};
13+
constexpr std::string_view cUnrecognizedErrorCode{"Unrecognized Error Code"};
14+
constexpr std::array cFailureConditions{std::errc::not_connected, std::errc::timed_out};
15+
constexpr std::array cNoneFailureConditions{std::errc::broken_pipe, std::errc::address_in_use};
16+
} // namespace ystdlib::error_handling::test
17+
18+
#endif // YSTDLIB_ERROR_HANDLING_TEST_CONSTANTS_HPP

src/ystdlib/error_handling/test-Defs.cpp renamed to src/ystdlib/error_handling/test-types.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
#include "test-Defs.hpp"
1+
#include "test-types.hpp"
22

33
#include <algorithm>
4-
#include <array>
54
#include <string>
65
#include <string_view>
76
#include <system_error>
87

8+
#include "test-constants.hpp"
9+
10+
using ystdlib::error_handling::test::AlwaysSuccessErrorCategory;
11+
using ystdlib::error_handling::test::AlwaysSuccessErrorCodeEnum;
12+
using ystdlib::error_handling::test::BinaryErrorCategory;
13+
using ystdlib::error_handling::test::BinaryErrorCodeEnum;
14+
using ystdlib::error_handling::test::cAlwaysSuccessErrorCategoryName;
15+
using ystdlib::error_handling::test::cBinaryTestErrorCategoryName;
16+
using ystdlib::error_handling::test::cFailureConditions;
17+
using ystdlib::error_handling::test::cFailureErrorMsg;
18+
using ystdlib::error_handling::test::cSuccessErrorMsg;
19+
using ystdlib::error_handling::test::cUnrecognizedErrorCode;
20+
921
template <>
1022
auto AlwaysSuccessErrorCategory::name() const noexcept -> char const* {
1123
return cAlwaysSuccessErrorCategoryName.data();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef YSTDLIB_ERROR_HANDLING_TEST_TYPES_HPP
2+
#define YSTDLIB_ERROR_HANDLING_TEST_TYPES_HPP
3+
4+
#include <cstdint>
5+
6+
#include <ystdlib/error_handling/ErrorCode.hpp>
7+
8+
namespace ystdlib::error_handling::test {
9+
enum class AlwaysSuccessErrorCodeEnum : uint8_t {
10+
Success = 0
11+
};
12+
13+
enum class BinaryErrorCodeEnum : uint8_t {
14+
Success = 0,
15+
Failure
16+
};
17+
18+
using AlwaysSuccessErrorCode = ystdlib::error_handling::ErrorCode<AlwaysSuccessErrorCodeEnum>;
19+
using AlwaysSuccessErrorCategory
20+
= ystdlib::error_handling::ErrorCategory<AlwaysSuccessErrorCodeEnum>;
21+
using BinaryErrorCode = ystdlib::error_handling::ErrorCode<BinaryErrorCodeEnum>;
22+
using BinaryErrorCategory = ystdlib::error_handling::ErrorCategory<BinaryErrorCodeEnum>;
23+
} // namespace ystdlib::error_handling::test
24+
25+
YSTDLIB_ERROR_HANDLING_MARK_AS_ERROR_CODE_ENUM(
26+
ystdlib::error_handling::test::AlwaysSuccessErrorCodeEnum
27+
);
28+
YSTDLIB_ERROR_HANDLING_MARK_AS_ERROR_CODE_ENUM(ystdlib::error_handling::test::BinaryErrorCodeEnum);
29+
30+
#endif // YSTDLIB_ERROR_HANDLING_TEST_TYPES_HPP

0 commit comments

Comments
 (0)