<commit_before>///
/// @file   wheel_sieve.cpp
/// @brief  Test the Wheel class which is used to skip
///         multiples of 2, 3, 5 and 7 in the sieve of
///         Eratosthenes.
///
/// Copyright (C) 2017 <NAME>, <<EMAIL>>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///

#include <Wheel.hpp>
#include <generate.hpp>
#include <imath.hpp>

#include <stdint.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <random>

using namespace std;
using namespace primecount;

void check(bool OK)
{
  cout << "   " << (OK ? "OK" : "ERROR") << "\n";
  if (!OK)
    exit(1);
}

int main()
{
  random_device rd;
  mt19937 gen(rd());
  uniform_int_distribution<int> dist(1000000, 2000000);

  int low = dist(gen);
  auto primes = generate_primes<int>(isqrt(low));
  Wheel wheel(primes, primes.size(), low);

  for (size_t i = 5; i < primes.size(); i++)
  {
    int j = low;

    while (j % primes[i] != 0 ||
           j % 2 == 0 ||
           j % 3 == 0 ||
           j % 5 == 0 ||
           j % 7 == 0)
    {
      j++;
    }

    auto multiple = wheel[i].next_multiple;
    cout << "wheel.multiple(" << low << ", " << primes[i] << ") = " << multiple;
    check(multiple == j);
  }

  cout << endl;
  cout << "All tests passed successfully!" << endl;

  return 0;
}
<commit_msg>Add 2nd test case<commit_after>///
/// @file   wheel_sieve.cpp
/// @brief  Test the Wheel class which is used to skip
///         multiples of 2, 3, 5 and 7 in the sieve of
///         Eratosthenes.
///
/// Copyright (C) 2017 <NAME>, <<EMAIL>>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///

#include <Wheel.hpp>
#include <generate.hpp>
#include <imath.hpp>

#include <stdint.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <random>

using namespace std;
using namespace primecount;

void check(bool OK)
{
  cout << "   " << (OK ? "OK" : "ERROR") << "\n";
  if (!OK)
    exit(1);
}

int main()
{
  random_device rd;
  mt19937 gen(rd());
  uniform_int_distribution<int> dist(1000000, 2000000);

  int low = dist(gen);
  auto primes = generate_primes<int>(isqrt(low));
  Wheel wheel(primes, primes.size(), low);

  // test 1st multiple >= low
  for (size_t i = 5; i < primes.size(); i++)
  {
    int j = low;

    while (j % primes[i] != 0 ||
           j % 2 == 0 ||
           j % 3 == 0 ||
           j % 5 == 0 ||
           j % 7 == 0)
    {
      j++;
    }

    auto multiple = wheel[i].next_multiple;
    cout << "wheel.multiple(" << low << ", " << primes[i] << ") = " << multiple;
    check(multiple == j);
  }

  // test 2nd multiple >= low
  for (size_t i = 5; i < primes.size(); i++)
  {
    auto multiple = wheel[i].next_multiple;
    auto j = multiple + 1;

    while (j % primes[i] != 0 ||
           j % 2 == 0 ||
           j % 3 == 0 ||
           j % 5 == 0 ||
           j % 7 == 0)
    {
      j++;
    }

    int64_t wheel_index = wheel[i].wheel_index;
    multiple += primes[i] * Wheel::next_multiple_factor(&wheel_index);

    cout << "wheel.next_multiple = " << multiple;
    check(multiple == j);
  }

  cout << endl;
  cout << "All tests passed successfully!" << endl;

  return 0;
}

{'fraction_non_alphanumeric': 0.178099046447247, 'fraction_numerical': 0.02891418025223008, 'mean_word_length': 2.301522842639594, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 31, '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': '1737867', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1124, 'n_words': 345}