u02/tests: Fix skipping behaviour

When the test runner only tests one case, it exits with a non-zero exit
code should that test invoke a skip (even if there are 1000+ successful
iterations).

This fixes this by falling back to a cheap message to stderr.
This commit is contained in:
Simon Bruder 2023-05-13 21:34:49 +02:00
parent ad02a06db4
commit 8f784ccf3e

View file

@ -5,6 +5,7 @@
#include <catch2/generators/catch_generators_adapters.hpp>
#include <catch2/generators/catch_generators_random.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <iostream>
#include "bresenham_circle_tool.h"
#include "bresenham_line_tool.h"
@ -349,7 +350,12 @@ TEST_CASE("Bresenham circle (prop: √(x²+y²)-r<ε)") {
if ((x0 == min_c || x0 == max_c) && (x1 == min_c || x1 == max_c) &&
(y0 == min_c || y0 == max_c) && (y1 == min_c || y1 == max_c)) {
SKIP("All coordinates have extreme value, skipping (avoid rounding error)");
// catch2s SKIP macro does not exactly do what I want here,
// so this just returns from the function and prints a message.
std::cerr
<< "All coordinates have extreme value, skipping (avoid rounding error)"
<< std::endl;
return;
}
const float r =
@ -537,7 +543,11 @@ TEST_CASE("Star (prop: all points inside circle)") {
if ((x0 == min_c || x0 == max_c) && (x1 == min_c || x1 == max_c) &&
(y0 == min_c || y0 == max_c) && (y1 == min_c || y1 == max_c)) {
SKIP("All coordinates have extreme value, skipping (avoid rounding error)");
// see above
std::cerr
<< "All coordinates have extreme value, skipping (avoid rounding error)"
<< std::endl;
return;
}
const float r = std::sqrt(std::pow((x1 - x0), 2) + std::pow((y1 - y0), 2));