<filename>CXX/tests/utils_tests/primes_test.cpp
/*
 * Project Euler - Utils - primes (Tests)
 * <NAME> <<EMAIL>>
 * Copyright (c) 2019 <NAME>
 *
 * Functions for finding prime numbers.
 */

#include <euler/utils/primes.hpp>

#include <vector> // std::vector

#include <catch2/catch.hpp>


namespace euler
{

// is_prime(n)
TEST_CASE("42 is not prime")
{
    REQUIRE(!utils::is_prime(42));
}

TEST_CASE("13 is prime")
{
    REQUIRE(utils::is_prime(13));
}

TEST_CASE("1 is not prime")
{
    REQUIRE(!utils::is_prime(1));
}

TEST_CASE("Long number prime check")
{
    REQUIRE(utils::is_prime(79L));
}

// find_next_prime(start)
TEST_CASE("First prime nuber is 2")
{
    REQUIRE(utils::find_next_prime(0) == 2);
}

TEST_CASE("The next prime number after 7 is 11")
{
    REQUIRE(utils::find_next_prime(7) == 11);
}

TEST_CASE("There are no prime numbers between 251 and 255 (uint8_t aka byte)")
{
    REQUIRE(utils::find_next_prime((uint8_t) 251) == (uint8_t) 0);
}


// primes_up_to(max)
TEST_CASE("The primes below 20 are { 2, 3, 5, 7, 11, 13, 17, 19 }")
{
    auto nums = std::vector<int> { 2, 3, 5, 7, 11, 13, 17, 19 };
    REQUIRE(utils::primes_up_to<int>(20) == nums);
}


} // end namespace euler
