From 26439fbf2763f8e9c84eec0bae76427d26cdfcd4 Mon Sep 17 00:00:00 2001 From: andreyvdl Date: Wed, 11 Oct 2023 00:10:01 -0300 Subject: [PATCH] test: added 5 tests for true and false the tests were based on the mandelbrot map --- graphics/mandelbrot.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/graphics/mandelbrot.c b/graphics/mandelbrot.c index 97e6f1a5..e8275892 100644 --- a/graphics/mandelbrot.c +++ b/graphics/mandelbrot.c @@ -26,11 +26,36 @@ A complex number is considered part of the mandelbrot set if he doesn't #include /// for math functions #include /// for boolean #include /// for size_t +#include /// for printf #define MAX_ITERATIONS 100 /// the maximum iterations to be made bool point_is_part_of_mandelbrot(double real, double imaginary); +/** +@brief The function that makes all the tests + +@return void + */ +void test(void) +{ + // tests that resulted in true + assert(point_is_part_of_mandelbrot(0.0, 0.0) == true); + assert(point_is_part_of_mandelbrot(-1.123, 0.0) == true); + assert(point_is_part_of_mandelbrot(0.25, 0.0) == true); + assert(point_is_part_of_mandelbrot(-1.3, 0.0) == true); + assert(point_is_part_of_mandelbrot(-0.1, -0.7) == true); + + // tests that resulted in false + assert(point_is_part_of_mandelbrot(42.0, 0.0) == false); + assert(point_is_part_of_mandelbrot(0.0, -42.0) == false); + assert(point_is_part_of_mandelbrot(-1.123, 2.0) == false); + assert(point_is_part_of_mandelbrot(-1.123, -2.0) == false); + assert(point_is_part_of_mandelbrot(1.0, -1.0) == false); + + printf("Passed in all tests :)\n"); +} + /** @brief The main function @@ -38,6 +63,7 @@ bool point_is_part_of_mandelbrot(double real, double imaginary); */ int main(void) { + test(); return 0; }