File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
Expand file tree Collapse file tree 3 files changed +14
-4
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 33#include < sstream>
44
55TEST_CASE (" Error Construction" ) {
6- const errors::Error err = errors::make (" unknown error" );
6+ const auto err = errors::make (" unknown error" );
7+ REQUIRE (err);
78 REQUIRE (err.message () == " unknown error" );
89}
910
10- TEST_CASE (" Error Checking" ) {
11- const auto err = errors::make (" unknown error" );
12- REQUIRE (err);
11+ TEST_CASE (" Empty Error Construction" ) {
12+ const errors::Error err;
13+ REQUIRE_FALSE (err);
14+ REQUIRE (err.message () == " no error" );
1315}
1416
1517TEST_CASE (" Error Printing Using OStream" ) {
You can’t perform that action at this time.
0 commit comments