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 {
18
18
Error (const std::shared_ptr<const std::string>& message_ptr);
19
19
20
20
public:
21
+
22
+ /* *
23
+ * @brief Constructs an empty error object.
24
+ */
25
+ Error ();
26
+
21
27
/* *
22
28
* @brief Returns the error message.
23
29
*
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ namespace errors {
4
4
5
5
Error::Error (const std::shared_ptr<const std::string>& message_ptr) : message_ptr(message_ptr) {}
6
6
7
+ Error::Error () {}
8
+
7
9
std::string_view Error::message () const {
8
10
if (!message_ptr) return " no error" ;
9
11
return *message_ptr;
Original file line number Diff line number Diff line change 3
3
#include < sstream>
4
4
5
5
TEST_CASE (" Error Construction" ) {
6
- const errors::Error err = errors::make (" unknown error" );
6
+ const auto err = errors::make (" unknown error" );
7
+ REQUIRE (err);
7
8
REQUIRE (err.message () == " unknown error" );
8
9
}
9
10
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" );
13
15
}
14
16
15
17
TEST_CASE (" Error Printing Using OStream" ) {
You can’t perform that action at this time.
0 commit comments