Skip to content

Commit

Permalink
debug common 7
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-urban committed Jul 2, 2024
1 parent 28a61a3 commit 2ef076f
Showing 1 changed file with 77 additions and 77 deletions.
154 changes: 77 additions & 77 deletions src/tests/vectorinterpolators/common.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,88 +178,88 @@ TEST_CASE("VectorInterpolators: should throw expected exceptions", TESTTAG)
{
INFO("Interpolator:" << interpolator->info_string());

// interpolator should fail if double x elements are appended
REQUIRE_THROWS(interpolator->append(12, -1));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
REQUIRE_THROWS(interpolator->append(11, -1));
interpolator->append(13, -1);
interpolator->set_data_XY(x, y);

// same for extending lists
REQUIRE_THROWS(interpolator->extend({ 12, 13 }, { -1, 1 }));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
REQUIRE_THROWS(interpolator->extend({ 11, 13 }, { -1, 1 }));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
REQUIRE_THROWS(interpolator->extend({ 14, 13 }, { -1, 1 }));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
REQUIRE_THROWS(interpolator->extend({ 14, 14 }, { -1, 1 }));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
interpolator->extend({ 13, 14 }, { -1, 1 });
REQUIRE(interpolator->get_data_X() != x);
REQUIRE(interpolator->get_data_Y() != y);
interpolator->set_data_XY(x, y);

// same for inserting lists (does not have to be sorted, but must be unique)
REQUIRE_THROWS(interpolator->insert({ 12, 13 }, { -1, 1 }));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
interpolator->insert({ 11, 13 }, { -1, 1 });
REQUIRE(interpolator->get_data_X() ==
std::vector<double>({ -10, -5, 0, 6, 11, 12, 13 }));
REQUIRE(themachinethatgoesping::tools::helper::approx_container(
interpolator->get_data_Y(), std::vector<double>({ 1, 0, 1, 0, -1, -1, 1 })));
interpolator->set_data_XY(x, y);
interpolator->insert({ 14, 13 }, { -1, 1 });
REQUIRE(interpolator->get_data_X() ==
std::vector<double>({ -10, -5, 0, 6, 12, 13, 14 }));
REQUIRE(themachinethatgoesping::tools::helper::approx_container(
interpolator->get_data_Y(), std::vector<double>({ 1, 0, 1, 0, -1, 1, -1 })));
interpolator->set_data_XY(x, y);
REQUIRE_THROWS(interpolator->insert({ 14, 14 }, { -1, 1 }));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
interpolator->insert({ 13, 14 }, { -1, 1 });
REQUIRE(interpolator->get_data_X() != x);
REQUIRE(interpolator->get_data_Y() != y);
interpolator->set_data_XY(x, y);

// initialize test data (wrong order)
std::vector<double> x_wrong_order_ = { -5, -10, 0, 6, 12 };

// throw because x is not sorted
REQUIRE_THROWS(interpolator->set_data_XY(x_wrong_order_, y));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee

// initialize test data (duplicates)
std::vector<double> x_duplicates_ = { -5, -10, 0, 0, 6, 12 };

// interpolator should fail if there is a double x element!
REQUIRE_THROWS(interpolator->set_data_XY(x_duplicates_, y));
REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// // interpolator should fail if double x elements are appended
// REQUIRE_THROWS(interpolator->append(12, -1));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// REQUIRE_THROWS(interpolator->append(11, -1));
// interpolator->append(13, -1);
// interpolator->set_data_XY(x, y);

// // same for extending lists
// REQUIRE_THROWS(interpolator->extend({ 12, 13 }, { -1, 1 }));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// REQUIRE_THROWS(interpolator->extend({ 11, 13 }, { -1, 1 }));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// REQUIRE_THROWS(interpolator->extend({ 14, 13 }, { -1, 1 }));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// REQUIRE_THROWS(interpolator->extend({ 14, 14 }, { -1, 1 }));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// interpolator->extend({ 13, 14 }, { -1, 1 });
// REQUIRE(interpolator->get_data_X() != x);
// REQUIRE(interpolator->get_data_Y() != y);
// interpolator->set_data_XY(x, y);

// // same for inserting lists (does not have to be sorted, but must be unique)
// REQUIRE_THROWS(interpolator->insert({ 12, 13 }, { -1, 1 }));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// interpolator->insert({ 11, 13 }, { -1, 1 });
// REQUIRE(interpolator->get_data_X() ==
// std::vector<double>({ -10, -5, 0, 6, 11, 12, 13 }));
// REQUIRE(themachinethatgoesping::tools::helper::approx_container(
// interpolator->get_data_Y(), std::vector<double>({ 1, 0, 1, 0, -1, -1, 1 })));
// interpolator->set_data_XY(x, y);
// interpolator->insert({ 14, 13 }, { -1, 1 });
// REQUIRE(interpolator->get_data_X() ==
// std::vector<double>({ -10, -5, 0, 6, 12, 13, 14 }));
// REQUIRE(themachinethatgoesping::tools::helper::approx_container(
// interpolator->get_data_Y(), std::vector<double>({ 1, 0, 1, 0, -1, 1, -1 })));
// interpolator->set_data_XY(x, y);
// REQUIRE_THROWS(interpolator->insert({ 14, 14 }, { -1, 1 }));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
// interpolator->insert({ 13, 14 }, { -1, 1 });
// REQUIRE(interpolator->get_data_X() != x);
// REQUIRE(interpolator->get_data_Y() != y);
// interpolator->set_data_XY(x, y);

// // initialize test data (wrong order)
// std::vector<double> x_wrong_order_ = { -5, -10, 0, 6, 12 };

// // throw because x is not sorted
// REQUIRE_THROWS(interpolator->set_data_XY(x_wrong_order_, y));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee

// // initialize test data (duplicates)
// std::vector<double> x_duplicates_ = { -5, -10, 0, 0, 6, 12 };

// // interpolator should fail if there is a double x element!
// REQUIRE_THROWS(interpolator->set_data_XY(x_duplicates_, y));
// REQUIRE(interpolator->get_data_X() == x); // strong exception guarantee
// REQUIRE(interpolator->get_data_Y() == y); // strong exception guarantee
}

// initialize test data (wrong order)
std::vector<double> x_wrong_order = { -5, -10, 0, 6, 12 };
// // initialize test data (wrong order)
// std::vector<double> x_wrong_order = { -5, -10, 0, 6, 12 };

// throw because x is not sorted
REQUIRE_THROWS(vectorinterpolators::LinearInterpolator(x_wrong_order, y));
REQUIRE_THROWS(vectorinterpolators::NearestInterpolator(x_wrong_order, y));
REQUIRE_THROWS(vectorinterpolators::AkimaInterpolator(x_wrong_order, y));
// // throw because x is not sorted
// REQUIRE_THROWS(vectorinterpolators::LinearInterpolator(x_wrong_order, y));
// REQUIRE_THROWS(vectorinterpolators::NearestInterpolator(x_wrong_order, y));
// REQUIRE_THROWS(vectorinterpolators::AkimaInterpolator(x_wrong_order, y));

// initialize test data (duplicates)
std::vector<double> x_duplicates = { -5, -10, 0, 0, 6, 12 };
// // initialize test data (duplicates)
// std::vector<double> x_duplicates = { -5, -10, 0, 0, 6, 12 };

// interpolator should fail if there is a double x element!
REQUIRE_THROWS(vectorinterpolators::AkimaInterpolator(x_duplicates, y));
REQUIRE_THROWS(vectorinterpolators::NearestInterpolator(x_duplicates, y));
REQUIRE_THROWS(vectorinterpolators::AkimaInterpolator(x_duplicates, y));
// // interpolator should fail if there is a double x element!
// REQUIRE_THROWS(vectorinterpolators::AkimaInterpolator(x_duplicates, y));
// REQUIRE_THROWS(vectorinterpolators::NearestInterpolator(x_duplicates, y));
// REQUIRE_THROWS(vectorinterpolators::AkimaInterpolator(x_duplicates, y));
}

SECTION("slerp interpolator")
Expand Down

0 comments on commit 2ef076f

Please sign in to comment.