You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "martinzink (via GitHub)" <gi...@apache.org> on 2023/09/19 12:25:28 UTC
[GitHub] [nifi-minifi-cpp] martinzink commented on a diff in pull request #1659: MINIFICPP-2218 Refactor expected monadic functions
martinzink commented on code in PR #1659:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1659#discussion_r1330043347
##########
libminifi/test/unit/ExpectedTest.cpp:
##########
@@ -153,124 +153,124 @@ TEST_CASE("expected map", "[expected][map]") {
// mapping functions which return references
{
nonstd::expected<int, int> e(42);
- auto ret = e | utils::map([](int& i) -> int& { return i; });
+ auto ret = e | utils::transform([](int& i) -> int& { return i; });
REQUIRE(ret);
REQUIRE(ret == 42);
}
}
-TEST_CASE("expected flatMap", "[expected][flatMap]") {
+TEST_CASE("expected andThen", "[expected][andThen]") {
auto succeed = [](int) { return nonstd::expected<int, int>(21 * 2); };
auto fail = [](int) { return nonstd::expected<int, int>(nonstd::unexpect, 17); };
{
nonstd::expected<int, int> e = 21;
- auto ret = e | utils::flatMap(succeed);
+ auto ret = e | utils::andThen(succeed);
REQUIRE(ret);
REQUIRE(*ret == 42);
}
{
const nonstd::expected<int, int> e = 21;
- auto ret = e | utils::flatMap(succeed);
+ auto ret = e | utils::andThen(succeed);
REQUIRE(ret);
REQUIRE(*ret == 42);
}
{
nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::flatMap(succeed);
+ auto ret = std::move(e) | utils::andThen(succeed);
REQUIRE(ret);
REQUIRE(*ret == 42);
}
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::flatMap(succeed); // NOLINT(performance-move-const-arg)
+ auto ret = std::move(e) | utils::andThen(succeed); // NOLINT(performance-move-const-arg)
REQUIRE(ret);
REQUIRE(*ret == 42);
}
{
nonstd::expected<int, int> e = 21;
- auto ret = e | utils::flatMap(fail);
+ auto ret = e | utils::andThen(fail);
REQUIRE(!ret);
REQUIRE(ret.error() == 17);
}
{
const nonstd::expected<int, int> e = 21;
- auto ret = e | utils::flatMap(fail);
+ auto ret = e | utils::andThen(fail);
REQUIRE(!ret);
REQUIRE(ret.error() == 17);
}
{
nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::flatMap(fail);
+ auto ret = std::move(e) | utils::andThen(fail);
REQUIRE(!ret);
REQUIRE(ret.error() == 17);
}
{
const nonstd::expected<int, int> e = 21;
- auto ret = std::move(e) | utils::flatMap(fail); // NOLINT(performance-move-const-arg)
+ auto ret = std::move(e) | utils::andThen(fail); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 17);
}
{
nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = e | utils::flatMap(succeed);
+ auto ret = e | utils::andThen(succeed);
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = e | utils::flatMap(succeed);
+ auto ret = e | utils::andThen(succeed);
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::flatMap(succeed);
+ auto ret = std::move(e) | utils::andThen(succeed);
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::flatMap(succeed); // NOLINT(performance-move-const-arg)
+ auto ret = std::move(e) | utils::andThen(succeed); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = e | utils::flatMap(fail);
+ auto ret = e | utils::andThen(fail);
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = e | utils::flatMap(fail);
+ auto ret = e | utils::andThen(fail);
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::flatMap(fail);
+ auto ret = std::move(e) | utils::andThen(fail);
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
{
const nonstd::expected<int, int> e(nonstd::unexpect, 21);
- auto ret = std::move(e) | utils::flatMap(fail); // NOLINT(performance-move-const-arg)
+ auto ret = std::move(e) | utils::andThen(fail); // NOLINT(performance-move-const-arg)
REQUIRE(!ret);
REQUIRE(ret.error() == 21);
}
Review Comment:
There is a TEST_CASE here with a comment
`// commented out parts depend on https://github.com/martinmoene/expected-lite/pull/40 (waiting for release)`
I think we upgraded to the release which it dependend upon. Could you enable those test cases aswell?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org