File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ class Error {
1818 Error (const std::shared_ptr<const std::string>& message_ptr);
1919
2020 public:
21+
22+ /* *
23+ * @brief Constructs an empty error object.
24+ */
25+ Error ();
26+
2127 /* *
2228 * @brief Returns the error message.
2329 *
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ namespace errors {
44
55Error::Error (const std::shared_ptr<const std::string>& message_ptr) : message_ptr(message_ptr) {}
66
7+ Error::Error () {}
8+
79std::string_view Error::message () const {
810 if (!message_ptr) return " no error" ;
911 return *message_ptr;
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ TEST_CASE("Error Construction") {
88 REQUIRE (err.message () == " unknown error" );
99}
1010
11+ TEST_CASE (" Empty Error Construction" ) {
12+ const errors::Error err;
13+ REQUIRE_FALSE (err);
14+ REQUIRE (err.message () == " no error" );
15+ }
16+
1117TEST_CASE (" Error Printing Using OStream" ) {
1218 const auto err = errors::make (" unknown error" );
1319 const auto ss = std::stringstream () << err;
You can’t perform that action at this time.
0 commit comments