imageInputTests.c erweitert
This commit is contained in:
parent
c212109a27
commit
86d225f2d8
@ -4,6 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "imageInput.h"
|
#include "imageInput.h"
|
||||||
|
#define FILE_HEADER_STRING "__info2_image_file_format__"
|
||||||
|
|
||||||
|
|
||||||
static void prepareImageFile(const char *path, unsigned short int width, unsigned short int height, unsigned int short numberOfImages, unsigned char label)
|
static void prepareImageFile(const char *path, unsigned short int width, unsigned short int height, unsigned int short numberOfImages, unsigned char label)
|
||||||
@ -64,6 +65,19 @@ static void prepareImageFileIncorrectTag(const char *path, unsigned short int wi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_readImagesFailsOnIncompleteHeader(void) {
|
||||||
|
const char *path = "testIncompleteHeader.info2";
|
||||||
|
FILE *file = fopen(path, "wb");
|
||||||
|
if (file) {
|
||||||
|
fwrite(FILE_HEADER_STRING, 1, strlen(FILE_HEADER_STRING), file);
|
||||||
|
|
||||||
|
unsigned char incompleteHeader[2] = {0x01, 0x00};
|
||||||
|
fwrite(incompleteHeader, 1, 2, file);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
TEST_ASSERT_NULL(readImages(path));
|
||||||
|
remove(path);
|
||||||
|
}
|
||||||
|
|
||||||
void test_readImagesReturnsCorrectNumberOfImages(void)
|
void test_readImagesReturnsCorrectNumberOfImages(void)
|
||||||
{
|
{
|
||||||
@ -179,6 +193,7 @@ int main()
|
|||||||
RUN_TEST(test_readImagesReturnsNullOnNotExistingPath);
|
RUN_TEST(test_readImagesReturnsNullOnNotExistingPath);
|
||||||
RUN_TEST(test_readImagesFailsOnWrongFileTag);
|
RUN_TEST(test_readImagesFailsOnWrongFileTag);
|
||||||
RUN_TEST(test_openImageFileIncorrectTag);
|
RUN_TEST(test_openImageFileIncorrectTag);
|
||||||
|
RUN_TEST(test_readImagesFailsOnIncompleteHeader);
|
||||||
|
|
||||||
return UNITY_END();
|
return UNITY_END();
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user