Skip to content

Commit

Permalink
audit wording in the API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed Jan 19, 2023
1 parent 190bc38 commit 4589a0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions include/result/err.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace res {
* dynamically.
*
* @code
* res::Result result = res::ErrStream() << "not found " << 404;
* res::Result result = res::ErrStream() << 404 << " not found";
* assert(result.is_err());
* assert(result.unwrap_err() == "not found 404");
* assert(result.unwrap_err() == "404 not found");
* @endcode
*/
struct ErrStream : public std::stringstream {};
Expand All @@ -32,7 +32,7 @@ struct ErrStream : public std::stringstream {};
* @endcode
*/
struct Err : public std::string {
/** Construct new error data using a C++ string.
/** Construct a new error data using a C++ string.
* @param err_msg The error message.
*
* @code
Expand All @@ -42,7 +42,7 @@ struct Err : public std::string {
*/
Err(const std::string& err_msg) : std::string(err_msg) {}

/** Construct new error data using a C-style string.
/** Construct a new error data using a C-style string.
* @param err_msg The error message.
*
* @code
Expand All @@ -52,12 +52,12 @@ struct Err : public std::string {
*/
Err(const char* err_msg) : std::string(err_msg) {}

/** Construct new error data using an error stream.
/** Construct a new error data using an error stream.
* @param err_stream The error stream.
*
* @code
* res::Err err = res::ErrStream() << "not found " << 404;
* assert(err == "not found 404");
* res::Err err = res::ErrStream() << 404 << " not found";
* assert(err == "404 not found");
* @endcode
*/
Err(const ErrStream& err_stream) : std::string(err_stream.str()) {}
Expand Down
8 changes: 4 additions & 4 deletions test/code_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ TEST_CASE("test code snippet") {
assert(err == "unknown error");
}
SECTION("Err(const ErrStream&) constructor") {
res::Err err = res::ErrStream() << "not found " << 404;
assert(err == "not found 404");
res::Err err = res::ErrStream() << 404 << " not found";
assert(err == "404 not found");
}
}
SECTION("res::ErrStream struct") {
res::Result result = res::ErrStream() << "not found " << 404;
res::Result result = res::ErrStream() << 404 << " not found";
assert(result.is_err());
assert(result.unwrap_err() == "not found 404");
assert(result.unwrap_err() == "404 not found");
}
}

0 comments on commit 4589a0d

Please sign in to comment.