xgboost/tests/cpp/metric/test_metric.cc
Jiaming Yuan 3e26107a9c
Rename and extract Context. (#8528)
* Rename `GenericParameter` to `Context`.
* Rename header file to reflect the change.
* Rename all references.
2022-12-07 04:58:54 +08:00

21 lines
600 B
C++

// Copyright by Contributors
#include <xgboost/metric.h>
#include "../helpers.h"
TEST(Metric, UnknownMetric) {
auto ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
xgboost::Metric * metric = nullptr;
EXPECT_ANY_THROW(metric = xgboost::Metric::Create("unknown_name", &ctx));
EXPECT_NO_THROW(metric = xgboost::Metric::Create("rmse", &ctx));
if (metric) {
delete metric;
}
metric = nullptr;
EXPECT_ANY_THROW(metric = xgboost::Metric::Create("unknown_name@1", &ctx));
EXPECT_NO_THROW(metric = xgboost::Metric::Create("error@0.5f", &ctx));
if (metric) {
delete metric;
}
}