Skip to content

Commit

Permalink
Issue #138 staging
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Lospinoso committed Jan 21, 2020
1 parent 2fc8596 commit 1fad3b1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions chapter_18/algorithms.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -462,16 +462,18 @@ TEST_CASE("merge") {
} }


TEST_CASE("max and min") { TEST_CASE("max and min") {
using namespace std::literals;
auto length_compare = [](const auto& x1, const auto& x2) { return x1.length() < x2.length(); }; auto length_compare = [](const auto& x1, const auto& x2) { return x1.length() < x2.length(); };


REQUIRE(min("undiscriminativeness"s, "vermin"s, length_compare) == "vermin"); string undisc="undiscriminativeness", vermin="vermin";
REQUIRE(min(undisc, vermin, length_compare) == "vermin");


REQUIRE(max("maxim"s, "ultramaximal"s, length_compare) == "ultramaximal"); string maxim="maxim", ultra="ultramaximal";
REQUIRE(max(maxim, ultra, length_compare) == "ultramaximal");


const auto result = minmax("minimaxes"s, "maximin"s, length_compare); string mini="minimaxes", maxi="maximin";
REQUIRE(result.first == "maximin"); const auto result = minmax(mini, maxi, length_compare);
REQUIRE(result.second == "minimaxes"); REQUIRE(result.first == maxi);
REQUIRE(result.second == mini);
} }


TEST_CASE("min and max element") { TEST_CASE("min and max element") {
Expand Down

0 comments on commit 1fad3b1

Please sign in to comment.