Skip to content

Commit

Permalink
#1376: tests: add spec-related to enum conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
nlslatt committed May 27, 2021
1 parent d2336fc commit 3c0b43f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/unit/lb/test_lbargs_enum_conv.nompi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
*/

#include "vt/vrt/collection/balance/lb_args_enum_converter.h"
#include "vt/vrt/collection/balance/read_lb.h"

#include "test_harness.h"

Expand Down Expand Up @@ -101,4 +102,33 @@ TEST_F(TestLBArgsEnumConverter, test_enum_converter_mapping) {
checkString(dummy_, "Three");
}

TEST_F(TestLBArgsEnumConverter, test_enum_converter_spec) {
vrt::collection::balance::LBArgsEnumConverter<DummyEnum> dummy_(
"dummy", "DummyEnum", {
{DummyEnum::One, "One"},
{DummyEnum::Two, "Two"},
{DummyEnum::Three, "Three"}
}
);
// normally this wouldn't reuse the same enum, but we're just testing
// spec-related stuff here so it's fine
vrt::collection::balance::LBArgsEnumConverter<DummyEnum> count_(
"count", "DummyEnum", {
{DummyEnum::One, "One"},
{DummyEnum::Two, "Two"},
{DummyEnum::Three, "Three"}
}
);

std::string spec_string("dummy=Two"); // deliberately omit 'count='
auto spec = vrt::collection::balance::ReadLBSpec::makeSpecFromParams(
spec_string
);

// explicitly specified should return specified value
EXPECT_EQ(dummy_.getFromSpec(&spec, DummyEnum::One), DummyEnum::Two);
// unspecified should return default value
EXPECT_EQ(count_.getFromSpec(&spec, DummyEnum::One), DummyEnum::One);
}

}}} // end namespace vt::tests::unit

0 comments on commit 3c0b43f

Please sign in to comment.