diff --git a/Implementierung/main.c b/Implementierung/main.c index 734c097..169fc0b 100644 --- a/Implementierung/main.c +++ b/Implementierung/main.c @@ -20,11 +20,6 @@ void save_bmp(const char *filename, unsigned char *img, size_t width, ssize_t height,_Bool color); -unsigned tests(void) { - return 0; - // run the tests -} - void benchmarking(size_t benchmarking_amount, int version_to_use, float complex complexA, size_t width, ssize_t height, float resolution, unsigned n, _Bool colored, unsigned char *tempArr) { struct timespec start; struct timespec end; @@ -68,6 +63,35 @@ void benchmarking(size_t benchmarking_amount, int version_to_use, float complex printf("Average time per function:%lf", average); } +unsigned tests(void) { + + printf("Doing testing\n\n"); + size_t width = 1920; + size_t height = 1080; + unsigned char *tempArrColored = malloc(width*height*3); + unsigned char *tempArrNotColored = malloc(width*height*1); + if (tempArrColored == NULL || tempArrNotColored == NULL) + { + fprintf(stderr,"Failed to allocate space for image\n"); + return EXIT_FAILURE; + } + + printf("\nTest 1: Default image, not coloured\n"); + benchmarking(3,0,-2.0f - 0.5f*I, width, height, 0.001f, 200, false, tempArrNotColored); + printf("\nTest 2: Default image, coloured\n"); + benchmarking(3,0,-2.0f - 0.5f*I, width, height, 0.001f, 200, true, tempArrColored); + printf("\nTest 3: High iteration count\n"); + benchmarking(3,0,-2.0f - 0.5f*I, width, height, 0.001f, 5000, false, tempArrNotColored); + printf("\nTest 4: Zoomed image\n"); + benchmarking(3,0,-0.5f - 0.5f*I, 1024, 1024, 0.0005f, 500, false, tempArrNotColored); + + free(tempArrColored); + free(tempArrNotColored); + + return 0; + // run the tests +} + // REMOVE LATER: interesting test command ./tricorn -s -2.0,0.6 -r 0.0010 -n 200 -d 1920,1080 -o image.bmp -C // AND FOR NEGATIVE HEIGHT: ./tricorn -s -2,-0.5 -r 0.0010 -n 200 -d 1920,-1080 -o image.bmp -C @@ -139,6 +163,7 @@ int main(int argc, char** argv) int version_to_use = 0; // actual initial value _Bool colored = 0; // actual initial value _Bool will_benchmark = false; // actual initial value + _Bool will_test = false; int amount_function_called = 0; // initial values, so that the compiler doesn't complain unsigned n = 0; @@ -268,11 +293,12 @@ int main(int argc, char** argv) return EXIT_SUCCESS; case 't': // done, function needed + will_test = true; // Führt eine vordefinierte Testsuite aus, welche sämtliche von Ihnen // verwendete Benchmarking-Szenarien gesammelt durchläuft. Das Programm gibt // die jeweiligen Parameter, eine kurze Beschreibungen sowie die Ergebnisse in einer // übersichtlichen und gut lesbaren Form aus und terminiert anschließend. - return tests() ? EXIT_FAILURE : EXIT_SUCCESS; + break; default: // idk // case '?' -> when the argument is not valid @@ -293,6 +319,11 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } + if (will_test) + { + return tests() ? EXIT_FAILURE : EXIT_SUCCESS; + } + if (will_benchmark) { printf("\nwill do benchmarking. no images will be created\n"); @@ -301,8 +332,6 @@ int main(int argc, char** argv) return 0; } - - printf("yashar\n"); switch (version_to_use) { case 0: @@ -332,7 +361,7 @@ int main(int argc, char** argv) default: break; } - printf("yashar\n"); + save_bmp(output_data,tempArr,width,height,colored); free(output_data);