<commit_before><commit_msg>tests/cpp: Add tests for metric.cc<commit_after>// Copyright by Contributors
#include <xgboost/metric.h>

#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"));
}
{'fraction_non_alphanumeric': 0.17772511848341233, 'fraction_numerical': 0.0071090047393364926, 'mean_word_length': 9.317073170731707, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1859904', 'n_tokens_mistral': 151, 'n_tokens_neox': 154, 'n_words': 18}