<commit_before>#include "system/moments/spherical_harmonic.h"

#include <array>

#include "test_helpers/gmock_wrapper.h"

namespace  {

using namespace bart;

using ::testing::Ref;

class SystemMomentsSphericalHarmonicTest : public ::testing::Test {
 protected:

  SystemMomentsSphericalHarmonicTest()
      : test_moments(total_groups, max_harmonic_l) {};

  // Test object
  system::moments::SphericalHarmonic test_moments;

  // Test parameters
  static constexpr int max_harmonic_l = 2;
  static constexpr int total_groups = 2;
};

TEST_F(SystemMomentsSphericalHarmonicTest, Constructor) {
  EXPECT_EQ(test_moments.total_groups(), total_groups);
  EXPECT_EQ(test_moments.max_harmonic_l(), max_harmonic_l);
  int total_moments = total_groups * (max_harmonic_l + 1) * (max_harmonic_l + 1);
  EXPECT_EQ(test_moments.moments().size(), total_moments);
}

TEST_F(SystemMomentsSphericalHarmonicTest, BadGroupsAndHarmonics) {
  std::array<int, 2> bad_groups{0, -1};
  std::array<int, 1> bad_max_harmonic_l{-1};

  for (const auto group : bad_groups) {
    for (const auto max_harmonic_l : bad_max_harmonic_l) {
      EXPECT_ANY_THROW({
        system::moments::SphericalHarmonic bad_moment(group, max_harmonic_l);
      });
    }
  }
}

TEST_F(SystemMomentsSphericalHarmonicTest, BracketOperator) {
  for (const auto& moment_pair : test_moments.moments()) {
    const auto& moment = test_moments[moment_pair.first];
    EXPECT_THAT(moment, Ref(moment_pair.second));
  }
}

TEST_F(SystemMomentsSphericalHarmonicTest, Assignment) {
  system::moments::MomentVector moment{10};<commit_msg>added test for const version of operator[] in SphericalHarmonic<commit_after>#include "system/moments/spherical_harmonic.h"

#include <array>

#include "test_helpers/gmock_wrapper.h"

namespace  {

using namespace bart;

using ::testing::Ref;

class SystemMomentsSphericalHarmonicTest : public ::testing::Test {
 protected:

  SystemMomentsSphericalHarmonicTest()
      : test_moments(total_groups, max_harmonic_l) {}

  // Test objects
  system::moments::SphericalHarmonic test_moments;

  // Test parameters
  static constexpr int max_harmonic_l = 2;
  static constexpr int total_groups = 2;
};

TEST_F(SystemMomentsSphericalHarmonicTest, Constructor) {
  EXPECT_EQ(test_moments.total_groups(), total_groups);
  EXPECT_EQ(test_moments.max_harmonic_l(), max_harmonic_l);
  int total_moments = total_groups * (max_harmonic_l + 1) * (max_harmonic_l + 1);
  EXPECT_EQ(test_moments.moments().size(), total_moments);
}

TEST_F(SystemMomentsSphericalHarmonicTest, BadGroupsAndHarmonics) {
  std::array<int, 2> bad_groups{0, -1};
  std::array<int, 1> bad_max_harmonic_l{-1};

  for (const auto group : bad_groups) {
    for (const auto max_harmonic_l : bad_max_harmonic_l) {
      EXPECT_ANY_THROW({
        system::moments::SphericalHarmonic bad_moment(group, max_harmonic_l);
      });
    }
  }
}

TEST_F(SystemMomentsSphericalHarmonicTest, BracketOperator) {
  for (const auto& moment_pair : test_moments.moments()) {
    const auto& moment = test_moments[moment_pair.first];
    EXPECT_THAT(moment, Ref(moment_pair.second));
  }

  const auto& const_test_moments = test_moments;

  for (const auto& moment_pair : const_test_moments.moments()) {
    const auto& moment = const_test_moments[moment_pair.first];
    EXPECT_THAT(moment, Ref(moment_pair.second));
  }

}

TEST_F(SystemMomentsSphericalHarmonicTest, Assignment) {
  system::moments::MomentVector moment{10};
{'fraction_non_alphanumeric': 0.1114012184508268, 'fraction_numerical': 0.006382361473745286, 'mean_word_length': 5.695145631067962, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1080955', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1191, 'n_words': 204}