From 75da256e3e1dc3a86f57944ca8fe6007dfe53627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Mon, 24 Feb 2025 14:42:14 +0100 Subject: [PATCH] Add missing tests for PartitionerOptions --- src/utils/PartitionerOptions.hpp | 4 +--- tests/test_PartitionerOptions.cpp | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/utils/PartitionerOptions.hpp b/src/utils/PartitionerOptions.hpp index b17180e0b..7adce0db4 100644 --- a/src/utils/PartitionerOptions.hpp +++ b/src/utils/PartitionerOptions.hpp @@ -43,9 +43,7 @@ getPartitionerEnumFromName(const std::string& enum_name) return PartitionerEnumType{enum_value}; } } - // LCOV_EXCL_START - throw UnexpectedError(std::string{"could not find '"} + enum_name + "' associate type!"); - // LCOV_EXCL_STOP + throw NormalError(std::string{"could not find '"} + enum_name + "' associate type!"); } class PartitionerOptions diff --git a/tests/test_PartitionerOptions.cpp b/tests/test_PartitionerOptions.cpp index 9f0605b4e..d1de1dde0 100644 --- a/tests/test_PartitionerOptions.cpp +++ b/tests/test_PartitionerOptions.cpp @@ -13,7 +13,33 @@ TEST_CASE("PartitionerOptions", "[utils]") REQUIRE(name(PartitionerLibrary::ptscotch) == "PTScotch"); REQUIRE_THROWS_WITH(name(PartitionerLibrary::PT__end), "unexpected error: Partitioner library name is not defined!"); + } + + SECTION("type from name") + { + REQUIRE(getPartitionerEnumFromName<PartitionerLibrary>("ParMETIS") == PartitionerLibrary::parmetis); + REQUIRE(getPartitionerEnumFromName<PartitionerLibrary>("PTScotch") == PartitionerLibrary::ptscotch); + + REQUIRE_THROWS_WITH(getPartitionerEnumFromName<PartitionerLibrary>("foobar"), + "error: could not find 'foobar' associate type!"); + } + + SECTION("output") + { + { + PartitionerOptions options; + options.library() = PartitionerLibrary::parmetis; + std::stringstream os; + os << options; + REQUIRE(os.str() == " library: ParMETIS\n"); + } - WARN("not finished"); + { + PartitionerOptions options; + options.library() = PartitionerLibrary::ptscotch; + std::stringstream os; + os << options; + REQUIRE(os.str() == " library: PTScotch\n"); + } } } -- GitLab