MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / removeFromLineTest

Method removeFromLineTest

test/path_object_t.cpp:712–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710}
711
712void PathObjectTest::removeFromLineTest()
713{
714 QFETCH(int, part_index);
715 QFETCH(float, cut_begin);
716 QFETCH(float, cut_end);
717 QFETCH(int, expected_size);
718
719 auto compare_head = [](auto& actual, auto& expected) {
720 QVERIFY(actual.getCoordinateCount() <= expected.getCoordinateCount());
721 QVERIFY(std::equal(
722 begin(actual.getRawCoordinateVector()),
723 end(actual.getRawCoordinateVector()) - 1, // cut point may differ
724 begin(expected.getRawCoordinateVector()),
725 equalXY) );
726 };
727
728 auto compare_tail = [](auto& actual, auto& expected) {
729 QVERIFY(actual.getCoordinateCount() <= expected.getCoordinateCount());
730 QVERIFY(std::equal(
731 rbegin(actual.getRawCoordinateVector()),
732 rend(actual.getRawCoordinateVector()) - 1, // cut point may differ
733 rbegin(expected.getRawCoordinateVector()),
734 equalXY) );
735 };
736
737 auto compare_mixed = [](auto& actual, auto& expected, bool forward) {
738 QVERIFY(actual.getCoordinateCount() <= expected.getCoordinateCount() + 2);
739 auto expected_join = expected.getCoordinate(0);
740 auto join = std::find_if(
741 begin(actual.getRawCoordinateVector()),
742 end(actual.getRawCoordinateVector()),
743 [expected_join](auto& current) { return equalXY(current, expected_join); } );
744
745 if (!forward)
746 {
747 QEXPECT_FAIL("0.4..0.6", "Removing from closed path across the closing point", Abort);
748 }
749 QVERIFY(join != end(actual.getRawCoordinateVector()));
750
751 QVERIFY(std::equal(
752 join,
753 end(actual.getRawCoordinateVector()) - 1, // cut point may differ
754 begin(expected.getRawCoordinateVector()),
755 equalXY) );
756
757 auto rjoin = std::find_if(
758 rbegin(actual.getRawCoordinateVector()),
759 rend(actual.getRawCoordinateVector()),
760 [expected_join](auto& current) { return equalXY(current, expected_join); } );
761 QVERIFY(rjoin != rend(actual.getRawCoordinateVector()));
762 QVERIFY(std::equal(
763 rjoin,
764 rend(actual.getRawCoordinateVector()) -1, // cut point may differ
765 rbegin(expected.getRawCoordinateVector()),
766 equalXY) );
767 };
768
769 // For 0.0 or 1.0, products are not precise enough.

Callers

nothing calls this directly

Calls 9

equalXYFunction · 0.85
getCoordinateCountMethod · 0.80
getCoordinateMethod · 0.80
updatePathCoordsMethod · 0.80
removeFromLineMethod · 0.80
backMethod · 0.80
addCoordinateMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected