From b802e24abd6ce4c1104bff58351166748d890d69 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 18 Nov 2025 01:12:09 +0100 Subject: [PATCH] imageInputTests Kommentiert --- imageInput.c | 7 ++----- imageInputTests.c | 11 +++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/imageInput.c b/imageInput.c index 5b827ba..a4f56de 100644 --- a/imageInput.c +++ b/imageInput.c @@ -11,14 +11,11 @@ // Datei öffnen + Header prüfen + Metadaten lesen // ===================================================== -static FILE *openFileAndReadHeader(const char *path, - unsigned short *count, - unsigned short *width, - unsigned short *height) +static FILE *openFileAndReadHeader(const char *path, unsigned short *count, unsigned short *width, unsigned short *height) { // Schritt 1: Datei öffnen FILE *file = fopen(path, "rb"); - if (!file) { + if (!file) { fprintf(stderr, "Error: Cannot open file '%s'\n", path); return NULL; } diff --git a/imageInputTests.c b/imageInputTests.c index c509b03..e1a5ea9 100644 --- a/imageInputTests.c +++ b/imageInputTests.c @@ -132,7 +132,7 @@ void test_openFileAndReadHeaderFailsOnZeroImageCount(void) FILE *file = fopen(path, "wb"); if (file != NULL) { const char *fileTag = "__info2_image_file_format__"; - unsigned short zero_count = 0; + unsigned short zero_count = 0; unsigned short width = 28; unsigned short height = 28; @@ -156,7 +156,7 @@ void test_openFileAndReadHeaderFailsOnZeroWidth(void) if (file != NULL) { const char *fileTag = "__info2_image_file_format__"; unsigned short count = 5; - unsigned short width = 0; // INVALID + unsigned short width = 0; unsigned short height = 28; fwrite(fileTag, sizeof(fileTag[0]), strlen(fileTag), file); @@ -179,7 +179,7 @@ void test_openFileAndReadHeaderFailsOnZeroHeight(void) const char *fileTag = "__info2_image_file_format__"; unsigned short count = 5; unsigned short width = 28; - unsigned short height = 0; // INVALID + unsigned short height = 0; fwrite(fileTag, sizeof(fileTag[0]), strlen(fileTag), file); fwrite(&count, sizeof(unsigned short), 1, file); @@ -210,13 +210,12 @@ void test_openFileAndReadHeaderFailsOnTruncatedHeader(void) void test_openFileAndReadHeaderFailsOnMissingCount(void) { - // Test: Datei hat Header aber kein count Feld + // Test: Datei hat Header aber keine Meta Daten const char *path = "testMissingCount.info2"; FILE *file = fopen(path, "wb"); if (file != NULL) { const char *fileTag = "__info2_image_file_format__"; fwrite(fileTag, sizeof(fileTag[0]), strlen(fileTag), file); - // count Feld nicht schreiben → EOF beim fread fclose(file); } @@ -248,7 +247,7 @@ void test_openFileAndReadHeaderCorrectMetadataOrder(void) if (file != NULL) { const char *fileTag = "__info2_image_file_format__"; unsigned short count = 10; - unsigned short width = 16; // WICHTIG: width vor height (Anzahl, Breite, Höhe) + unsigned short width = 16; // Anzahl, Breite, Höhe unsigned short height = 32; unsigned char label = 5; unsigned char pixel_data[16*32];