File indexing completed on 2024-04-06 12:15:41
0001 #define CATCH_CONFIG_MAIN
0002 #include <catch.hpp>
0003
0004 #include "HeterogeneousCore/AlpakaInterface/interface/Backend.h"
0005
0006 TEST_CASE("Test cms::alpakatools::toBackend", "cms::alpakatools::Backend") {
0007 SECTION("Valid string") {
0008 REQUIRE(cms::alpakatools::toBackend("SerialSync") == cms::alpakatools::Backend::SerialSync);
0009 REQUIRE(cms::alpakatools::toBackend("CudaAsync") == cms::alpakatools::Backend::CudaAsync);
0010 REQUIRE(cms::alpakatools::toBackend("ROCmAsync") == cms::alpakatools::Backend::ROCmAsync);
0011 REQUIRE(cms::alpakatools::toBackend("TbbAsync") == cms::alpakatools::Backend::TbbAsync);
0012 }
0013 SECTION("Invalid string") {
0014 REQUIRE_THROWS_WITH(cms::alpakatools::toBackend("Nonexistent"),
0015 Catch::Contains("EnumNotFound") and Catch::Contains("Invalid backend name"));
0016 }
0017 }
0018
0019 TEST_CASE("Test cms::alpakatools::toString", "cms::alpakatools::Backend") {
0020 SECTION("Valid enum") {
0021 REQUIRE(cms::alpakatools::toString(cms::alpakatools::Backend::SerialSync) == "SerialSync");
0022 REQUIRE(cms::alpakatools::toString(cms::alpakatools::Backend::CudaAsync) == "CudaAsync");
0023 REQUIRE(cms::alpakatools::toString(cms::alpakatools::Backend::ROCmAsync) == "ROCmAsync");
0024 REQUIRE(cms::alpakatools::toString(cms::alpakatools::Backend::TbbAsync) == "TbbAsync");
0025 }
0026 SECTION("Invalid enum") {
0027 REQUIRE_THROWS_WITH(cms::alpakatools::toString(cms::alpakatools::Backend::size),
0028 Catch::Contains("InvalidEnumValue") and Catch::Contains("Invalid backend enum value"));
0029 }
0030 }