From 8f784ccf3e03c8e2a7b4817cdbb2be38a85bb67d Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 13 May 2023 21:34:49 +0200 Subject: [PATCH] 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. --- u02/src/tests.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/u02/src/tests.cpp b/u02/src/tests.cpp index cde85bb..81521ae 100644 --- a/u02/src/tests.cpp +++ b/u02/src/tests.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #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)"); + // catch2’s 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));