8000 Naming consistency by helly25 · Pull Request #71 · helly25/mbo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Naming consistency #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Added `mbo::status::StatusBuilder` which allows to modify the message of an `absl::Status`.
* Added `mbo::status::GetStatus` which allows to convert its argument to an `absl::Status` if supported.
* Added macro `MBO_MOVE_TO_OR_RETURN` which can assign to structured binadings and other complex types.
* Added macro `MBO_ASSERT_OK_AND_ASSIGN_TO` which can assign to structured binadings and other complex types.
* Added macro `MBO_ASSERT_OK_AND_MOVE_TO` which can assign to structured binadings and other complex types.
* Added matcher `mbo::testing::StatusHasPayload` that matches presence of any, a specific payload url, or a payload url with specific content.
* Added matcher `mbo::testing::StatusPayloads` that matches against `Status`/`StatusOr<>` payload maps.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The C++ library is organized in functional groups each residing in their own dir
* gmock-matcher `StatusHasPayload`: Tests whether an `absl::Status` or `absl::StatusOr` payload map has any payload, a specific payload url, or a payload url with specific content.
* gmock-matcher `StatusPayloads` Tests whether an `absl::Status` or `absl::StatusOr` payload map matches.
* macro `MBO_ASSERT_OK_AND_ASSIGN`: Simplifies testing with functions that return `absl::StatusOr<T>`.
* macro `MBO_ASSERT_OK_AND_ASSIGN_TO`: Simplifies testing with functions that return `absl::StatusOr<T>` where the result requires commas, in particular structured bindings.
* macro `MBO_ASSERT_OK_AND_MOVE_TO`: Simplifies testing with functions that return `absl::StatusOr<T>` where the result requires commas, in particular structured bindings.
* Types
* `namespace mbo::types`
* mbo/types:cases_cc, mbo/types/cases.h
Expand Down
12 changes: 6 additions & 6 deletions mbo/testing/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ inline ::testing::PolymorphicMatcher<testing_internal::StatusPayloads> StatusPay

#undef MBO_PRIVATE_TESTING_STATUS_ASSERT_OK_AND_ASSIGN_
#undef MBO_ASSERT_OK_AND_ASSIGN
#undef MBO_ASSERT_OK_AND_ASSIGN_TO
#undef MBO_ASSERT_OK_AND_MOVE_TO

// PRIVATE macro, do not use.
#define MBO_PRIVATE_TESTING_STATUS_ASSERT_OK_AND_ASSIGN_(statusor, expression, ...) \
Expand All @@ -452,19 +452,19 @@ inline ::testing::PolymorphicMatcher<testing_internal::StatusPayloads> StatusPay
// Macro that verifies `expression` is OK and assigns its `value` by move to `targets`, where target
// can be a declaration. Example:
// ```
// ASSERT_OK_OR_ASSIGN(const std::string result, StringOrStatus());
// MBO_ASSERT_OK_AND_ASSIGN(const std::string result, StringOrStatus());
// ```
#define MBO_ASSERT_OK_AND_ASSIGN(target, expression) \
MBO_PRIVATE_TESTING_STATUS_ASSERT_OK_AND_ASSIGN_( \
MBO_PRIVATE_TESTING_STATUS_CONCAT_(_status_or_value, __LINE__), expression, target)

// Variant of `ASSERT_OK_OR_ASSIGN` that allows to assign to complex types, in particular to
// Variant of `MBO_ASSERT_OK_AND_ASSIGN` that allows to assign to complex types, in particular to
// structured bindings. Example:
// ```
// ASSERT_OK_AND_ASSIGN_TO(PairOrStatus(), const auto [first, second]);
// MBO_ASSERT_OK_AND_MOVE_TO(PairOrStatus(), const auto [first, second]);
// ```
#define MBO_ASSERT_OK_AND_ASSIGN_TO(expression, ...) \
MBO_PRIVATE_TESTING_STATUS_ASSERT_OK_AND_ASSIGN_( \
#define MBO_ASSERT_OK_AND_MOVE_TO(expression, ...) \
MBO_PRIVATE_TESTING_STATUS_ASSERT_OK_AND_ASSIGN_( \
MBO_PRIVATE_TESTING_STATUS_CONCAT_(_status_or_value, __LINE__), expression, __VA_ARGS__)

#ifndef ASSERT_OK_AND_ASSIGN
Expand Down
2 changes: 1 addition & 1 deletion mbo/testing/status_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ TEST_F(StatusMatcherTest, AssertOkAndAssign) {

TEST_F(StatusMatcherTest, AssertOkAndAssignTo) {
absl::StatusOr<std::pair<int, int>> status_or(std::make_pair(25, 17));
MBO_ASSERT_OK_AND_ASSIGN_TO(status_or, auto [first, second]);
MBO_ASSERT_OK_AND_MOVE_TO(status_or, auto [first, second]);
EXPECT_THAT(std::make_pair(first, second), Pair(25, 17));
}

Expand Down
Loading
0