u02/tests: Use const where possible

filtered
Simon Bruder 2023-05-07 10:05:43 +02:00
parent b780d4b8c4
commit f81098f259
1 changed files with 19 additions and 19 deletions

View File

@ -62,8 +62,8 @@ TEST_CASE("Transform Rotate + Mirror") {
}
TEST_CASE("Transform = Inverse Transform ○ Transform") {
int x = GENERATE(take(10, random(-100, 100)));
int y = GENERATE(take(10, random(-100, 100)));
const int x = GENERATE(take(10, random(-100, 100)));
const int y = GENERATE(take(10, random(-100, 100)));
// this iterates over all possible transformations,
// even bogus ones (like rotating cw and ccw)
for (Transformation transformation = 0; transformation < 0b10000;
@ -99,7 +99,7 @@ TEST_CASE("Transformation to standard case (prop)") {
int x1 = GENERATE(take(10, random(-100, 100)));
int y1 = GENERATE(take(10, random(-100, 100)));
Transformation transformation =
const Transformation transformation =
transformation_to_standard_case(x0, y0, x1, y1);
transform_mut(transformation, x0, y0);
@ -118,7 +118,7 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
dda_line_tool *tool_dda = new dda_line_tool(*canvas);
tool_base *tool;
int tool_idx = GENERATE(0, 1);
const int tool_idx = GENERATE(0, 1);
switch (tool_idx) {
case 0:
tool = tool_bresenham;
@ -128,17 +128,17 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
break;
}
int x0 = GENERATE(take(10, random(0, size - 1)));
int y0 = GENERATE(take(10, random(0, size - 1)));
int x1 = GENERATE(take(10, random(0, size - 1)));
int y1 = GENERATE(take(10, random(0, size - 1)));
const int x0 = GENERATE(take(10, random(0, size - 1)));
const int y0 = GENERATE(take(10, random(0, size - 1)));
const int x1 = GENERATE(take(10, random(0, size - 1)));
const int y1 = GENERATE(take(10, random(0, size - 1)));
tool->draw(x0, y0, x1, y1);
int x_min = std::min(x0, x1);
int x_max = std::max(x0, x1);
int y_min = std::min(y0, y1);
int y_max = std::max(y0, y1);
const int x_min = std::min(x0, x1);
const int x_max = std::max(x0, x1);
const int y_min = std::min(y0, y1);
const int y_max = std::max(y0, y1);
// Depending on what the direction of the line (rounded to the next 90°) is,
// either every row or column has only one pixel set.
@ -191,7 +191,7 @@ TEST_CASE("Fill (recursive and non recursive) test shape") {
new non_recursive_fill_tool(*canvas);
tool_base *tool_fill;
int tool_fill_idx = GENERATE(0, 1);
const int tool_fill_idx = GENERATE(0, 1);
switch (tool_fill_idx) {
case 0:
tool_fill = tool_fill_recursive;
@ -241,16 +241,16 @@ TEST_CASE("Fill recursive == Fill non recursive (prop, 5 random lines)") {
new non_recursive_fill_tool(*canvas_non_recursive);
for (int i = 0; i < 5; i++) {
int x0 = GENERATE(take(1, random(0, size - 1)));
int y0 = GENERATE(take(1, random(0, size - 1)));
int x1 = GENERATE(take(1, random(0, size - 1)));
int y1 = GENERATE(take(1, random(0, size - 1)));
const int x0 = GENERATE(take(1, random(0, size - 1)));
const int y0 = GENERATE(take(1, random(0, size - 1)));
const int x1 = GENERATE(take(1, random(0, size - 1)));
const int y1 = GENERATE(take(1, random(0, size - 1)));
tool_line_recursive->draw(x0, y0, x1, y1);
tool_line_non_recursive->draw(x0, y0, x1, y1);
}
int x = GENERATE(take(3, random(0, size - 1)));
int y = GENERATE(take(3, random(0, size - 1)));
const int x = GENERATE(take(3, random(0, size - 1)));
const int y = GENERATE(take(3, random(0, size - 1)));
tool_fill_recursive->draw(x, y);
tool_fill_non_recursive->draw(x, y);