diff --git a/tests/test.cpp b/tests/test.cpp index 7bd637c..d81e79c 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -13,7 +13,7 @@ using namespace Catch; constexpr double TOLERANCE = 1e-4; -TEST_CASE("lehmer64 rng") +TEST_CASE("lehmer64 rng", "[test]") { s2ga::lehmer64 rng(0); @@ -56,11 +56,11 @@ TEST_CASE("lehmer64 rng") } } -TEST_CASE("Uniform Distribution Tests") +TEST_CASE("uniform distribution tests", "[test]") { s2ga::lehmer64 rng(42); // Fixed seed for reproducibility - SECTION("Integer Uniformity - Chi-Squared Test") + SECTION("integer uniformity - chi-squared test") { const int min = 0; const int max = 9; @@ -86,7 +86,7 @@ TEST_CASE("Uniform Distribution Tests") CHECK(chi_sq < critical_value); } - SECTION("Floating Point Uniformity - Kolmogorov-Smirnov Test") + SECTION("floating point uniformity - Kolmogorov-Smirnov test") { const double min = 0.0; const double max = 1.0; @@ -113,7 +113,7 @@ TEST_CASE("Uniform Distribution Tests") CHECK(d_stat < ks_critical); } - SECTION("Edge Case Coverage") + SECTION("edge case coverage") { const int iterations = 10'000; @@ -172,7 +172,7 @@ inline double sphere(double x, double y) return std::pow(x, 2.0) + std::pow(y, 2.0); } -TEST_CASE("sphere(0, 0) = 0") +TEST_CASE("sphere(0, 0) = 0", "[test]") { REQUIRE(sphere(0.0, 0.0) == Approx(0.0).margin(TOLERANCE)); } @@ -185,7 +185,7 @@ inline double ackley(double x, double y) std::numbers::e + 20.0; } -TEST_CASE("ackley(0, 0) = 0") +TEST_CASE("ackley(0, 0) = 0", "[test]") { REQUIRE(ackley(0.0, 0.0) == Approx(0.0).margin(TOLERANCE)); } @@ -198,7 +198,7 @@ inline double rastrigin(double x, double y) (std::pow(y, 2.0) - A * std::cos(2.0 * std::numbers::pi * y)); } -TEST_CASE("rastrigin(0, 0) = 0") +TEST_CASE("rastrigin(0, 0) = 0", "[test]") { REQUIRE(rastrigin(0.0, 0.0) == Approx(0.0).margin(TOLERANCE)); } @@ -208,7 +208,7 @@ inline double rosenbrock(double x, double y) return 100.0 * std::pow(y - std::pow(x, 2.0), 2.0) + std::pow(1.0 - x, 2.0); } -TEST_CASE("rosenbrock(1, 1) = 0") +TEST_CASE("rosenbrock(1, 1) = 0", "[test]") { REQUIRE(rosenbrock(1.0, 1.0) == Approx(0.0).margin(TOLERANCE)); } @@ -220,7 +220,7 @@ inline double bill(double x, double y) std::pow(2.625 - x + x * std::pow(y, 3.0), 2.0); } -TEST_CASE("bill(3, 0.5) = 0") +TEST_CASE("bill(3, 0.5) = 0", "[test]") { REQUIRE(bill(3.0, 0.5) == Approx(0.0).margin(TOLERANCE)); } @@ -235,7 +235,7 @@ inline double goldstein_price(double x, double y) 36.0 * x * y + 27.0 * std::pow(y, 2.0))); } -TEST_CASE("goldstein_price(0, -1) = 3") +TEST_CASE("goldstein_price(0, -1) = 3", "[test]") { REQUIRE(goldstein_price(0.0, -1.0) == Approx(3.0).margin(TOLERANCE)); } @@ -245,7 +245,7 @@ inline double booth(double x, double y) return std::pow(x + 2.0 * y - 7.0, 2.0) + std::pow(2.0 * x + y - 5.0, 2.0); } -TEST_CASE("booth(1, 3) = 0") +TEST_CASE("booth(1, 3) = 0", "[test]") { REQUIRE(booth(1.0, 3.0) == Approx(0.0).margin(TOLERANCE)); } @@ -256,7 +256,7 @@ inline double bukin_n6(double x, double y) 0.01 * std::abs(x + 10.0); } -TEST_CASE("bukin_n6(-10, 1) = 0") +TEST_CASE("bukin_n6(-10, 1) = 0", "[test]") { REQUIRE(bukin_n6(-10.0, 1.0) == Approx(0.0).margin(TOLERANCE)); } @@ -266,7 +266,7 @@ inline double matyas(double x, double y) return 0.26 * sphere(x, y) - 0.48 * x * y; } -TEST_CASE("matyas(0, 0) = 0") +TEST_CASE("matyas(0, 0) = 0", "[test]") { REQUIRE(matyas(0.0, 0.0) == Approx(0.0).margin(TOLERANCE)); } @@ -283,7 +283,7 @@ inline double levi_n13(double x, double y) std::pow(y - 1.0, 2.0) * (1.0 + sin2(2.0 * std::numbers::pi * y)); } -TEST_CASE("levi_n13(1, 1) = 0") +TEST_CASE("levi_n13(1, 1) = 0", "[test]") { REQUIRE(levi_n13(1.0, 1.0) == Approx(0.0).margin(TOLERANCE)); } @@ -294,7 +294,7 @@ inline double three_hump_camel(double x, double y) std::pow(x, 6.0) / 6.0 + x * y + std::pow(y, 2.0); } -TEST_CASE("three_hump_camel(0, 0) = 0") +TEST_CASE("three_hump_camel(0, 0) = 0", "[test]") { REQUIRE(three_hump_camel(0.0, 0.0) == Approx(0.0).margin(TOLERANCE)); } @@ -305,7 +305,7 @@ inline double eggholder(double x, double y) x * std::sin(std::sqrt(std::abs(x - (y + 47.0)))); } -TEST_CASE("eggholder(512, 404.2319) = -959.6407") +TEST_CASE("eggholder(512, 404.2319) = -959.6407", "[test]") { REQUIRE(eggholder(512.0, 404.2319) == Approx(-959.6407).margin(TOLERANCE)); } @@ -315,7 +315,7 @@ inline double mccormick(double x, double y) return std::sin(x + y) + std::pow(x - y, 2.0) - 1.5 * x + 2.5 * y + 1.0; } -TEST_CASE("mccormick(-0.54719, -1.54719) = -1.9133") +TEST_CASE("mccormick(-0.54719, -1.54719) = -1.9133", "[test]") { REQUIRE(mccormick(-0.54719, -1.54719) == Approx(-1.9133).margin(TOLERANCE)); } @@ -326,7 +326,7 @@ inline double schaffer_n2(double x, double y) std::pow(1.0 + 0.001 * sphere(x, y), 2.0); } -TEST_CASE("schaffer_n2(0, 0) = 0") +TEST_CASE("schaffer_n2(0, 0) = 0", "[test]") { REQUIRE(schaffer_n2(0.0, 0.0) == Approx(0.0).margin(TOLERANCE)); } @@ -344,12 +344,12 @@ inline double schaffer_n4(double x, double y) std::pow(1.0 + 0.001 * sphere(x, y), 2.0); } -TEST_CASE("schaffer_n4(0, 1.25313) = 0.292579") +TEST_CASE("schaffer_n4(0, 1.25313) = 0.292579", "[test]") { REQUIRE(schaffer_n4(0.0, 1.25313) == Approx(0.292579).margin(TOLERANCE)); } -TEST_CASE("Should pass") +TEST_CASE("Should pass", "[test]") { REQUIRE_NOTHROW(foo()); }