diff --git a/tests/cpp/metric/test_metric.cc b/tests/cpp/metric/test_metric.cc new file mode 100644 index 000000000..0e715472e --- /dev/null +++ b/tests/cpp/metric/test_metric.cc @@ -0,0 +1,11 @@ +// Copyright by Contributors +#include + +#include "../helpers.h" + +TEST(Metric, UnknownMetric) { + EXPECT_ANY_THROW(xgboost::Metric::Create("unknown_name")); + EXPECT_NO_THROW(xgboost::Metric::Create("rmse")); + EXPECT_ANY_THROW(xgboost::Metric::Create("unknown_name@1")); + EXPECT_NO_THROW(xgboost::Metric::Create("error@0.5")); +}