<commit_before>//===-- ClusteringTest.cpp --------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "Clustering.h"
#include "BenchmarkResult.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace llvm {
namespace exegesis {

namespace {

using testing::Field;
using testing::UnorderedElementsAre;
using testing::UnorderedElementsAreArray;

static constexpr auto HasPoints = [](const std::vector<int> &Indices) {
  return Field(&InstructionBenchmarkClustering::Cluster::PointIndices,
                 UnorderedElementsAreArray(Indices));
};

TEST(ClusteringTest, Clusters3D) {
  std::vector<InstructionBenchmark> Points(6);

  // Cluster around (x=0, y=1, z=2): points {0, 3}.
  Points[0].Measurements = {
      {"x", 0.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
  Points[3].Measurements = {<commit_msg>[llvm-exegesis] Fix compilation before c++17.<commit_after>//===-- ClusteringTest.cpp --------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "Clustering.h"
#include "BenchmarkResult.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace llvm {
namespace exegesis {

namespace {

using testing::Field;
using testing::UnorderedElementsAre;
using testing::UnorderedElementsAreArray;

static const auto HasPoints = [](const std::vector<int> &Indices) {
  return Field(&InstructionBenchmarkClustering::Cluster::PointIndices,
                 UnorderedElementsAreArray(Indices));
};

TEST(ClusteringTest, Clusters3D) {
  std::vector<InstructionBenchmark> Points(6);

  // Cluster around (x=0, y=1, z=2): points {0, 3}.
  Points[0].Measurements = {
      {"x", 0.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
  Points[3].Measurements = {
{'fraction_non_alphanumeric': 0.250628667225482, 'fraction_numerical': 0.024308466051969825, 'mean_word_length': 2.831460674157303, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '6881703', 'n_tokens_mistral': 769, 'n_tokens_neox': 745, 'n_words': 166}