Compare commits

..

No commits in common. "fe0728da3e4293ace0a7804302d002e524deb419" and "2f6a3a4391fb4e76410b668062c658b347ff0311" have entirely different histories.

3 changed files with 27 additions and 43 deletions

28
.gitignore vendored
View File

@ -1,7 +1,21 @@
# Alles ignorieren
*
# Ausnahmen: bestimmte Dateitypen in allen Verzeichnissen
!**/*.c
!**/*.h
!**/*Makefile
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

View File

@ -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, unsigned short greyScaleTest)
static void prepareImageFile(const char *path, unsigned short int width, unsigned short int height, unsigned int short numberOfImages, unsigned char label)
{
FILE *file = fopen(path, "wb");
@ -17,14 +17,6 @@ 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);
@ -49,7 +41,7 @@ void test_readImagesReturnsCorrectNumberOfImages(void)
GrayScaleImageSeries *series = NULL;
const unsigned short expectedNumberOfImages = 2;
const char *path = "testFile.info2";
prepareImageFile(path, 8, 8, expectedNumberOfImages, 1, 0);
prepareImageFile(path, 8, 8, expectedNumberOfImages, 1);
series = readImages(path);
TEST_ASSERT_NOT_NULL(series);
TEST_ASSERT_EQUAL_UINT16(expectedNumberOfImages, series->count);
@ -62,7 +54,7 @@ void test_readImagesReturnsCorrectImageWidth(void)
GrayScaleImageSeries *series = NULL;
const unsigned short expectedWidth = 10;
const char *path = "testFile.info2";
prepareImageFile(path, expectedWidth, 8, 2, 1, 0);
prepareImageFile(path, expectedWidth, 8, 2, 1);
series = readImages(path);
TEST_ASSERT_NOT_NULL(series);
TEST_ASSERT_NOT_NULL(series->images);
@ -78,7 +70,7 @@ void test_readImagesReturnsCorrectImageHeight(void)
GrayScaleImageSeries *series = NULL;
const unsigned short expectedHeight = 10;
const char *path = "testFile.info2";
prepareImageFile(path, 8, expectedHeight, 2, 1, 0);
prepareImageFile(path, 8, expectedHeight, 2, 1);
series = readImages(path);
TEST_ASSERT_NOT_NULL(series);
TEST_ASSERT_NOT_NULL(series->images);
@ -95,7 +87,7 @@ void test_readImagesReturnsCorrectLabels(void)
GrayScaleImageSeries *series = NULL;
const char *path = "testFile.info2";
prepareImageFile(path, 8, 8, 2, expectedLabel, 0);
prepareImageFile(path, 8, 8, 2, expectedLabel);
series = readImages(path);
TEST_ASSERT_NOT_NULL(series);
TEST_ASSERT_NOT_NULL(series->labels);
@ -127,27 +119,6 @@ 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
}
@ -167,7 +138,6 @@ int main()
RUN_TEST(test_readImagesReturnsCorrectLabels);
RUN_TEST(test_readImagesReturnsNullOnNotExistingPath);
RUN_TEST(test_readImagesFailsOnWrongFileTag);
RUN_TEST(test_readImagesReadsCorrectGrayScales);
return UNITY_END();
}

View File

@ -9,9 +9,9 @@ typedef float MatrixType;
typedef struct
{
MatrixType *buffer;
int rows;
int cols;
MatrixType *buffer;
} Matrix;