From c851767445f78fe42a28695ff31c47867107aa56 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 6 May 2023 21:09:59 +0200 Subject: [PATCH] u02: Implement recursive fill tool --- u02/src/tests.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/u02/src/tests.cpp b/u02/src/tests.cpp index a8c6331..d874248 100644 --- a/u02/src/tests.cpp +++ b/u02/src/tests.cpp @@ -8,6 +8,7 @@ #include "bresenham_line_tool.h" #include "canvas_buffer.h" #include "dda_line_tool.h" +#include "recursive_fill_tool.h" #include "util.h" TEST_CASE("Transform Mirror") { @@ -179,3 +180,23 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel " REQUIRE(all_sums_are_one); } + +TEST_CASE("Recursive fill simple") { + canvas_buffer *canvas = new canvas_buffer(100, 100); + bresenham_line_tool *tool_line = new bresenham_line_tool(*canvas); + recursive_fill_tool *tool = new recursive_fill_tool(*canvas); + + tool_line->draw(10, 10, 30, 10); + tool_line->draw(10, 10, 20, 30); + tool_line->draw(20, 30, 30, 10); + + tool->draw(15, 15); + + // 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)); +}