Compare commits
3 Commits
2f6a3a4391
...
fe0728da3e
| Author | SHA1 | Date | |
|---|---|---|---|
| fe0728da3e | |||
| dafd526828 | |||
| e67fb83d8f |
28
.gitignore
vendored
28
.gitignore
vendored
@ -1,21 +1,7 @@
|
||||
I2_Wortsalat/Start_Mac/wordsalad_initial
|
||||
I2_Wortsalat/Start_Mac/.DS_Store
|
||||
I2_Wortsalat/.DS_Store
|
||||
I2_Wortsalat/Start_Mac/input.o
|
||||
.gitignore
|
||||
I2_Wortsalat/Start_Mac/game.o
|
||||
I2_Wortsalat/Start_Mac/runTests
|
||||
.o
|
||||
.a
|
||||
.idea/editor.xml
|
||||
.idea/vcs.xml
|
||||
.idea/workspace.xml
|
||||
I2_Wortsalat/.idea/editor.xml
|
||||
I2_Wortsalat/.idea/I2_Wortsalat.iml
|
||||
I2_Wortsalat/.idea/modules.xml
|
||||
I2_Wortsalat/Start_Mac/main.o
|
||||
I2_Wortsalat/Start_Mac/.DS_Store
|
||||
I2_Wortsalat/Start_Mac/.DS_Store
|
||||
I2_Wortsalat/Start_Mac/wordsalad
|
||||
I2_Wortsalat/Start_Mac/graphicalGame.o
|
||||
.DS_Store
|
||||
# Alles ignorieren
|
||||
*
|
||||
|
||||
# Ausnahmen: bestimmte Dateitypen in allen Verzeichnissen
|
||||
!**/*.c
|
||||
!**/*.h
|
||||
!**/*Makefile
|
||||
@ -6,7 +6,7 @@
|
||||
#include "imageInput.h"
|
||||
|
||||
|
||||
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, unsigned short greyScaleTest)
|
||||
{
|
||||
FILE *file = fopen(path, "wb");
|
||||
|
||||
@ -17,6 +17,14 @@ static void prepareImageFile(const char *path, unsigned short int width, unsigne
|
||||
|
||||
if(zeroBuffer != NULL)
|
||||
{
|
||||
if(greyScaleTest)
|
||||
{
|
||||
for(unsigned int i = 0; i < (numberOfImages * width * height); i++)
|
||||
{
|
||||
zeroBuffer[i] = (GrayScalePixelType)i;
|
||||
}
|
||||
}
|
||||
|
||||
fwrite(fileTag, sizeof(fileTag[0]), strlen(fileTag), file);
|
||||
fwrite(&numberOfImages, sizeof(numberOfImages), 1, file);
|
||||
fwrite(&width, sizeof(width), 1, file);
|
||||
@ -41,7 +49,7 @@ void test_readImagesReturnsCorrectNumberOfImages(void)
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const unsigned short expectedNumberOfImages = 2;
|
||||
const char *path = "testFile.info2";
|
||||
prepareImageFile(path, 8, 8, expectedNumberOfImages, 1);
|
||||
prepareImageFile(path, 8, 8, expectedNumberOfImages, 1, 0);
|
||||
series = readImages(path);
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_EQUAL_UINT16(expectedNumberOfImages, series->count);
|
||||
@ -54,7 +62,7 @@ void test_readImagesReturnsCorrectImageWidth(void)
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const unsigned short expectedWidth = 10;
|
||||
const char *path = "testFile.info2";
|
||||
prepareImageFile(path, expectedWidth, 8, 2, 1);
|
||||
prepareImageFile(path, expectedWidth, 8, 2, 1, 0);
|
||||
series = readImages(path);
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_NOT_NULL(series->images);
|
||||
@ -70,7 +78,7 @@ void test_readImagesReturnsCorrectImageHeight(void)
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const unsigned short expectedHeight = 10;
|
||||
const char *path = "testFile.info2";
|
||||
prepareImageFile(path, 8, expectedHeight, 2, 1);
|
||||
prepareImageFile(path, 8, expectedHeight, 2, 1, 0);
|
||||
series = readImages(path);
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_NOT_NULL(series->images);
|
||||
@ -87,7 +95,7 @@ void test_readImagesReturnsCorrectLabels(void)
|
||||
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const char *path = "testFile.info2";
|
||||
prepareImageFile(path, 8, 8, 2, expectedLabel);
|
||||
prepareImageFile(path, 8, 8, 2, expectedLabel, 0);
|
||||
series = readImages(path);
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_NOT_NULL(series->labels);
|
||||
@ -119,6 +127,27 @@ void test_readImagesFailsOnWrongFileTag(void)
|
||||
remove(path);
|
||||
}
|
||||
|
||||
void test_readImagesReadsCorrectGrayScales(void)
|
||||
{
|
||||
GrayScaleImageSeries *series = NULL;
|
||||
const char *path = "testFile.info2";
|
||||
|
||||
prepareImageFile(path, 8, 8, 1, 1, 1);
|
||||
series = readImages(path);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(series);
|
||||
TEST_ASSERT_NOT_NULL(series->images);
|
||||
TEST_ASSERT_EQUAL_UINT16(1, series->count);
|
||||
|
||||
for (unsigned int i = 0; i < (8 * 8); i++)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_UINT8((GrayScalePixelType)i, series->images->buffer[i]);
|
||||
}
|
||||
|
||||
clearSeries(series);
|
||||
remove(path);
|
||||
}
|
||||
|
||||
void setUp(void) {
|
||||
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
|
||||
}
|
||||
@ -138,6 +167,7 @@ int main()
|
||||
RUN_TEST(test_readImagesReturnsCorrectLabels);
|
||||
RUN_TEST(test_readImagesReturnsNullOnNotExistingPath);
|
||||
RUN_TEST(test_readImagesFailsOnWrongFileTag);
|
||||
RUN_TEST(test_readImagesReadsCorrectGrayScales);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
@ -9,9 +9,9 @@ typedef float MatrixType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
MatrixType *buffer;
|
||||
int rows;
|
||||
int cols;
|
||||
MatrixType *buffer;
|
||||
} Matrix;
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user