1010
1111namespace {
1212constexpr std::string_view cCustomFailureDescription{" This operation has failed." };
13+ } // namespace
1314
15+ namespace ystdlib ::test {
1416class Worker {
1517public:
1618 YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION (OperationFailed);
@@ -30,20 +32,24 @@ class Worker {
3032 throw OperationFailed (std::make_error_code (std::errc::invalid_argument));
3133 }
3234};
35+ } // namespace ystdlib::test
36+
37+ using ystdlib::test::Worker;
3338
39+ namespace {
3440constexpr std::string_view cExecuteWithSuccessFunctionName{
35- " static void {anonymous} ::Worker::execute_with_success()"
41+ " static void ystdlib::test ::Worker::execute_with_success()"
3642};
3743constexpr std::string_view cExecuteWithFailureFunctionName{
38- " static void {anonymous} ::Worker::execute_with_failure()"
44+ " static void ystdlib::test ::Worker::execute_with_failure()"
3945};
4046constexpr std::string_view cExecuteWithInvalidArgsFunctionName{
41- " static void {anonymous} ::Worker::execute_with_invalid_args()"
47+ " static void ystdlib::test ::Worker::execute_with_invalid_args()"
4248};
4349constexpr std::string_view cInvalidArgsErrorMsg{" Invalid argument" };
44- constexpr auto cExecuteWithSuccessLineNumber{19 };
45- constexpr auto cExecuteWithFailureLineNumber{26 };
46- constexpr auto cExecuteWithInvalidArgsLineNumber{30 };
50+ constexpr auto cExecuteWithSuccessLineNumber{21 };
51+ constexpr auto cExecuteWithFailureLineNumber{28 };
52+ constexpr auto cExecuteWithInvalidArgsLineNumber{32 };
4753
4854#ifdef SOURCE_PATH_SIZE
4955constexpr auto cRelativePathFileName{std::string_view{__FILE__}.substr (SOURCE_PATH_SIZE)};
@@ -66,17 +72,12 @@ auto capture_exception(Callable&& f) -> ystdlib::error_handling::TraceableExcept
6672}
6773} // namespace
6874
69- #include < iostream>
70-
7175TEST_CASE (" test_traceable_exception_success" , " [error_handling][TraceableException]" ) {
7276 auto const success_exception{capture_exception (Worker::execute_with_success)};
7377 std::error_code const success_error_code{BinaryErrorCode{BinaryErrorCodeEnum::Success}};
7478 REQUIRE ((success_error_code.category () == success_exception.error_code ().category ()));
7579 REQUIRE ((success_error_code.value () == success_exception.error_code ().value ()));
7680 REQUIRE ((cSuccessErrorMsg == success_exception.error_code ().message ()));
77- std::cout << " A:" << cExecuteWithSuccessFunctionName << std::endl;
78- std::cout << " B:" << success_exception.what () << std::endl;
79- std::cout << " C:" << success_exception.function_name () << std::endl;
8081 REQUIRE ((cExecuteWithSuccessFunctionName == std::string_view{success_exception.what ()}));
8182 REQUIRE ((cExecuteWithSuccessFunctionName == success_exception.function_name ()));
8283 REQUIRE ((cExecuteWithSuccessLineNumber == success_exception.line ()));
0 commit comments