#include "catch/catch.hpp" #include "simple_pathfinding.h" #include "coordinates.h" #include "point.h" template static void test_path() { Point start; Point finish( point( 3, 0 ) ); Point max( point( 10, 10 ) ); const auto estimate = [&]( const pf::node &, const pf::node * ) { return 1; }; pf::path pth = pf::find_path( start, finish, max, estimate ); REQUIRE( pth.nodes.size() == 4 ); CHECK( pth.nodes[3].pos == Point() ); // NOLINTNEXTLINE(cata-use-named-point-constants) CHECK( pth.nodes[2].pos == Point( point( 1, 0 ) ) ); CHECK( pth.nodes[1].pos == Point( point( 2, 0 ) ) ); CHECK( pth.nodes[0].pos == Point( point( 3, 0 ) ) ); } TEST_CASE( "simple_line_path" ) { test_path(); test_path(); }