From 38da76bfb3c4348a200e45d3d9495d8ec4c0f151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=BChl?= Date: Tue, 16 Apr 2024 17:09:52 +0200 Subject: [PATCH] improved result test with specific error test --- test/ResultTest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/ResultTest.cpp b/test/ResultTest.cpp index 43e9f35..e84d093 100644 --- a/test/ResultTest.cpp +++ b/test/ResultTest.cpp @@ -25,7 +25,12 @@ utils::resultplus(int x, int y) { } utils::resulterror_to_string(math_error err) { - return utils::error(std::string("error")); + switch (err) { + case math_error::DIVISION_BY_ZERO: + return utils::error(std::string("division by zero error")); + default: + return utils::error(std::string("unknown error")); + } } } @@ -76,7 +81,7 @@ TEST_CASE("Result tests", "[result]") { REQUIRE(!res2); REQUIRE(!res2.is_ok()); REQUIRE(res2.is_error()); - REQUIRE((res2.err() == "error")); + REQUIRE((res2.err() == "division by zero error")); res = test::divide(4, 2) .and_then([](const auto &val) { return test::multiply(val, 5); })