u02: Implement bresenham line tool
This commit is contained in:
parent
240d5435f2
commit
649d5da18a
|
@ -5,6 +5,7 @@
|
|||
#include <catch2/generators/catch_generators_adapters.hpp>
|
||||
#include <catch2/generators/catch_generators_random.hpp>
|
||||
|
||||
#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)));
|
||||
|
|
Reference in a new issue