From 649d5da18ad127f795523144c65ac407774b5817 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 6 May 2023 18:41:11 +0200 Subject: [PATCH] u02: Implement bresenham line tool --- u02/src/tests.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/u02/src/tests.cpp b/u02/src/tests.cpp index 5090c1b..a8c6331 100644 --- a/u02/src/tests.cpp +++ b/u02/src/tests.cpp @@ -5,6 +5,7 @@ #include #include +#include "bresenham_line_tool.h" #include "canvas_buffer.h" #include "dda_line_tool.h" #include "util.h" @@ -105,10 +106,24 @@ TEST_CASE("Transformation to standard case (prop)") { REQUIRE(y0 >= y1); } -TEST_CASE("DDA line tool (prop: for every row/column, only one pixel is set)") { +TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel " + "is set)") { const int size = 100; canvas_buffer *canvas = new canvas_buffer(size, size); - dda_line_tool *tool = new dda_line_tool(*canvas); + + bresenham_line_tool *tool_bresenham = new bresenham_line_tool(*canvas); + dda_line_tool *tool_dda = new dda_line_tool(*canvas); + + tool_base *tool; + int tool_idx = GENERATE(0, 1); + switch (tool_idx) { + case 0: + tool = tool_bresenham; + break; + case 1: + tool = tool_dda; + break; + } int x0 = GENERATE(take(10, random(0, size - 1))); int y0 = GENERATE(take(10, random(0, size - 1)));