From b37e243a1e96bb99b42eff9295b448f0241a89b8 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 21 Dec 2023 01:02:50 +0100 Subject: Transform asserts into ifs for shapes test The asserts only take effect when building with them enabled. --- test/unit/shapes.cc | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/unit/shapes.cc b/test/unit/shapes.cc index 30aa7d81..f52eab82 100644 --- a/test/unit/shapes.cc +++ b/test/unit/shapes.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken + * Copyright 2023 Rodrigo Arias Mallo * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,24 +18,32 @@ * along with this program. If not, see . */ - - -#include "../dw/core.hh" +#include "dw/core.hh" using namespace dw::core; using namespace lout::misc; int main() { - Polygon poly; - poly.addPoint (50, 10); - poly.addPoint (90, 90); - poly.addPoint (10, 90); + Polygon poly; + poly.addPoint(50, 10); + poly.addPoint(90, 90); + poly.addPoint(10, 90); + + if (!poly.isPointWithin(50, 50)) { + printf("poly.isPointWithin(50, 50) failed\n"); + exit(1); + } + + if (poly.isPointWithin(10, 10)) { + printf("!poly.isPointWithin(10, 10) failed\n"); + exit(1); + } + + if (poly.isPointWithin(90, 50)) { + printf("!poly.isPointWithin(90, 50) failed\n"); + exit(1); + } - printf("first test\n"); - assert (poly.isPointWithin (50, 50)); - printf("second test\n"); - assert (!poly.isPointWithin (10, 10)); - printf("third test\n"); - assert (!poly.isPointWithin (90, 50)); + return 0; } -- cgit v1.2.3