u02: Replace fill test to use test shape

This commit is contained in:
Simon Bruder 2023-05-06 22:56:17 +02:00
parent dfeb329a52
commit 5a1ba0ca93

View file

@ -182,7 +182,7 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
REQUIRE(all_sums_are_one);
}
TEST_CASE("Fill (recursive and non recursive) simple") {
TEST_CASE("Fill (recursive and non recursive) test shape") {
canvas_buffer *canvas = new canvas_buffer(100, 100);
bresenham_line_tool *tool_line = new bresenham_line_tool(*canvas);
recursive_fill_tool *tool_fill_recursive = new recursive_fill_tool(*canvas);
@ -200,19 +200,27 @@ TEST_CASE("Fill (recursive and non recursive) simple") {
break;
}
tool_line->draw(10, 10, 30, 10);
tool_line->draw(10, 10, 20, 30);
tool_line->draw(20, 30, 30, 10);
canvas->draw_test_shape();
tool_fill->draw(15, 15);
REQUIRE_FALSE(canvas->get_pixel(50, 49));
REQUIRE_FALSE(canvas->get_pixel(50, 25));
REQUIRE_FALSE(canvas->get_pixel(50, 75));
tool_fill->draw(50, 25);
REQUIRE(canvas->get_pixel(50, 49));
REQUIRE(canvas->get_pixel(50, 25));
REQUIRE(canvas->get_pixel(50, 75));
// just some samples, not very thorough
REQUIRE(canvas->get_pixel(15, 15));
REQUIRE(canvas->get_pixel(20, 20));
REQUIRE(canvas->get_pixel(25, 20));
REQUIRE_FALSE(canvas->get_pixel(9, 9));
REQUIRE_FALSE(canvas->get_pixel(30, 9));
REQUIRE_FALSE(canvas->get_pixel(19, 30));
REQUIRE_FALSE(canvas->get_pixel(75, 40));
REQUIRE_FALSE(canvas->get_pixel(75, 60));
tool_fill->draw(75, 50);
REQUIRE(canvas->get_pixel(75, 40));
REQUIRE(canvas->get_pixel(75, 60));
REQUIRE_FALSE(canvas->get_pixel(0, 0));
REQUIRE_FALSE(canvas->get_pixel(99, 99));
tool_fill->draw(25, 50);
REQUIRE(canvas->get_pixel(0, 0));
REQUIRE(canvas->get_pixel(99, 99));
}
TEST_CASE("Fill recursive == Fill non recursive (prop, 5 random lines)") {