Fehlerbehebung 2 der unit_Test und Makefile Anpassung
This commit is contained in:
parent
f77c450c0f
commit
fefffcfdf5
@ -22,7 +22,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
for (unsigned int j = 0; j < searchFieldLen; ++j)
|
||||
{
|
||||
salad[i][j] = ' ';
|
||||
salad[i][j] = EMPTY_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
if (salad[i][j] == EMPTY_CHAR)
|
||||
{
|
||||
salad[i][j] = 'A' + rand() % 26;
|
||||
salad[i][j] = 'A' + (rand() % 26);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +1,38 @@
|
||||
#include "input.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAX_WORD_LEN 100
|
||||
|
||||
void capitalletters(char *str){
|
||||
void capitalletters(char *str) {
|
||||
while (*str) {
|
||||
*str = toupper((unsigned char) *str);
|
||||
*str = toupper((unsigned char)*str);
|
||||
str++;
|
||||
}
|
||||
|
||||
}
|
||||
// Liest Wörter aus Datei und speichert sie sicher im Array
|
||||
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
char buffer[MAX_WORD_LEN];
|
||||
char buffer[1024]; // größerer Puffer für ganze Zeile
|
||||
unsigned int count_word = 0;
|
||||
|
||||
|
||||
while (count_word < maxWordCount && fgets(buffer, sizeof(buffer), file) != NULL)
|
||||
{
|
||||
// Zeilenumbruch entfernen
|
||||
buffer[strcspn(buffer, "\r\n")] = '\0';
|
||||
|
||||
// Zeilenumbruch manuell entfernen
|
||||
for (int i = 0; i < MAX_WORD_LEN; i++)
|
||||
// Zerlege Zeile in Wörter anhand von Leerzeichen, Komma und Semikolon
|
||||
char *token = strtok(buffer, " ,;");
|
||||
|
||||
while (token != NULL && count_word < maxWordCount)
|
||||
{
|
||||
if (buffer[i] == '\n' || buffer[i] == '\r')
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
capitalletters(buffer);
|
||||
|
||||
// Sicheres Kopieren in das Zielarray
|
||||
strncpy(words[count_word], buffer, MAX_WORD_LEN - 1);
|
||||
words[count_word][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung sicherstellen
|
||||
|
||||
capitalletters(token); // Großschreiben
|
||||
strncpy(words[count_word], token, MAX_WORD_LEN - 1);
|
||||
words[count_word][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung
|
||||
count_word++;
|
||||
|
||||
token = strtok(NULL, " ,;");
|
||||
}
|
||||
}
|
||||
|
||||
return count_word;
|
||||
|
||||
@ -33,6 +33,8 @@ game.o: game.c
|
||||
graphicalGame.o: graphicalGame.c
|
||||
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
|
||||
|
||||
|
||||
|
||||
# --------------------------
|
||||
# Unit Tests
|
||||
# --------------------------
|
||||
@ -41,8 +43,16 @@ TEST_BIN = runTests
|
||||
test: input.o game.o unit_tests.c
|
||||
$(CC) $(CFLAGS) -I$(unityfolder) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a
|
||||
|
||||
$(BINARIES)/libwordsalad_complete.a: input.o game.o
|
||||
ar rcs $(BINARIES)/libwordsalad_complete.a input.o game.o
|
||||
|
||||
|
||||
wordsalad_myversion: main.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a
|
||||
$(CC) $(CFLAGS) -o wordsalad_myversion main.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||
|
||||
# --------------------------
|
||||
# Clean
|
||||
# --------------------------
|
||||
clean:
|
||||
del /f *.o *.exe
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user