Skip to content

Commit

Permalink
debug ci
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-urban committed Jul 2, 2024
1 parent eb90f84 commit 152fe97
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tests/vectorinterpolators/linear.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ TEST_CASE("LinearInterpolator: should perform basic interpolations correctly", T
double x_append = 12;
double y_append = -1;

INFO("Peter 0");
vectorinterpolators::LinearInterpolator interpolator(x, y);

// append some data
interpolator.append(x_append, y_append);

INFO("Peter 1");
SECTION("existing values should be looked up correctly")
{
for (unsigned int i = 0; i < x.size(); ++i)
Expand All @@ -36,12 +38,14 @@ TEST_CASE("LinearInterpolator: should perform basic interpolations correctly", T
REQUIRE(interpolator(x_append) == Catch::Approx(y_append));
}

INFO("Peter 2");
SECTION("const interpolation should produce the same results as classic interpolation")
{
for (double x_val = -10; x_val <= 12; x_val += 0.1)
REQUIRE(interpolator(x_val) == Catch::Approx(interpolator.get_y_const(x_val)));
}

INFO("Peter 3");
SECTION("preset values should be interpolated correctly")
{
CHECK(interpolator(-7.6) == Catch::Approx(0.52));
Expand All @@ -61,6 +65,7 @@ TEST_CASE("LinearInterpolator: should perform basic interpolations correctly", T
CHECK(interpolator(10) == Catch::Approx(-2. / 3.));
}

INFO("Peter 4");
SECTION("preset value vectors should be interpolated correctly")
{
std::vector<double> targets_x = { -2.6, -2.5, -2.4 };
Expand All @@ -69,6 +74,7 @@ TEST_CASE("LinearInterpolator: should perform basic interpolations correctly", T
REQUIRE(interpolator(targets_x) == expected_y);
}

INFO("Peter 5");
SECTION("extrapolation mode should cause:")
{
for (auto mode : vectorinterpolators::t_extr_mode_all)
Expand All @@ -80,29 +86,36 @@ TEST_CASE("LinearInterpolator: should perform basic interpolations correctly", T
case vectorinterpolators::t_extr_mode::fail:
SECTION(" - fail when set to fail")
{
INFO("Peter 6 1");
REQUIRE_THROWS_AS(interpolator(-11), std::out_of_range);
REQUIRE_THROWS_AS(interpolator(13), std::out_of_range);
REQUIRE_THROWS_AS(interpolator.get_y_const(-11), std::out_of_range);
REQUIRE_THROWS_AS(interpolator.get_y_const(13), std::out_of_range);

INFO("Peter 6 2");
}
break;

case vectorinterpolators::t_extr_mode::nearest:
SECTION(" - extrapolate nearest when set")
{
INFO("Peter 6 3");
REQUIRE(interpolator(-11) == Catch::Approx(1));
REQUIRE(interpolator(13) == Catch::Approx(y_append));
REQUIRE(interpolator.get_y_const(-11) == Catch::Approx(1));
REQUIRE(interpolator.get_y_const(13) == Catch::Approx(y_append));
INFO("Peter 6 4");
}
break;

default:
INFO("Peter 6 5");
SECTION(" - extrapolation in all other cases")
REQUIRE(interpolator(-11) == Catch::Approx(1.2));
REQUIRE(interpolator(14) == Catch::Approx(-4 / 3.));
REQUIRE(interpolator.get_y_const(-11) == Catch::Approx(1.2));
REQUIRE(interpolator.get_y_const(14) == Catch::Approx(-4 / 3.));
INFO("Peter 6 6");

break;
}
Expand Down

0 comments on commit 152fe97

Please sign in to comment.