Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6f3446fa8d | ||
![]() |
db1e31f237 | ||
![]() |
a9d6d69bc1 |
@ -1,9 +1,9 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -Wall
|
CFLAGS = -g -Wall -I$(raylibfolder)
|
||||||
LDFLAGS = -lGL -lX11 -lm
|
LDFLAGS = -lGL -lX11 -lm
|
||||||
BINARIES = ./linux
|
BINARIES = ./linux
|
||||||
|
|
||||||
raylibfolder = ./raylib
|
raylib_folder = ./raylib
|
||||||
unityfolder = ./unity
|
unityfolder = ./unity
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@ -28,7 +28,7 @@ game.o: game.c
|
|||||||
$(CC) $(CFLAGS) -c game.c
|
$(CC) $(CFLAGS) -c game.c
|
||||||
|
|
||||||
graphicalGame.o: graphicalGame.c
|
graphicalGame.o: graphicalGame.c
|
||||||
$(CC) $(CFLAGS) -I$(raylibfolder) -c graphicalGame.c
|
$(CC) $(CFLAGS) -c graphicalGame.c
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Unit Tests
|
# Unit Tests
|
||||||
|
@ -101,37 +101,7 @@ void test_createWordSalad_too_small(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_createWordSalad_allWordsPlaced() {
|
|
||||||
char words[3][MAX_WORD_LEN] = {"CAT", "DOG", "MOUSE"};
|
|
||||||
char saladHoriz[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
||||||
char saladVert[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
||||||
|
|
||||||
int placed = createWordSalad(saladHoriz, 20, words, 3);
|
|
||||||
for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++)
|
|
||||||
{
|
|
||||||
saladVert[j][i] = saladHoriz[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++) {
|
|
||||||
const char* word = words[i];
|
|
||||||
int wordFound = 0;
|
|
||||||
for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++)
|
|
||||||
{
|
|
||||||
const char* row = saladHoriz[j];
|
|
||||||
const char* col = saladVert[j];
|
|
||||||
wordFound |= strstr(row, word) || strstr(col, word);
|
|
||||||
}
|
|
||||||
TEST_ASSERT_TRUE_MESSAGE(wordFound, "Not all words were placed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(3, placed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Test Setup und TearDown Funktionen ----------
|
// ---------- Test Setup und TearDown Funktionen ----------
|
||||||
|
|
||||||
// Hier Setup- und TearDown-Funktionen definieren,
|
// Hier Setup- und TearDown-Funktionen definieren,
|
||||||
// falls Vor- und Nachbereitungen für die Tests benötigt.
|
// falls Vor- und Nachbereitungen für die Tests benötigt.
|
||||||
|
|
||||||
@ -164,7 +134,6 @@ int main(void) {
|
|||||||
RUN_TEST(test_readWords_empty_file);
|
RUN_TEST(test_readWords_empty_file);
|
||||||
RUN_TEST(test_createWordSalad_all_fit);
|
RUN_TEST(test_createWordSalad_all_fit);
|
||||||
RUN_TEST(test_createWordSalad_too_small);
|
RUN_TEST(test_createWordSalad_too_small);
|
||||||
RUN_TEST(test_createWordSalad_allWordsPlaced);
|
|
||||||
|
|
||||||
int result = UNITY_END(); // Test-Ergebnisse
|
int result = UNITY_END(); // Test-Ergebnisse
|
||||||
print_test_result(result);
|
print_test_result(result);
|
||||||
|
@ -4,7 +4,7 @@ LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -f
|
|||||||
ARCH := $(shell uname -m)
|
ARCH := $(shell uname -m)
|
||||||
BINARIES = ./macos-$(ARCH)
|
BINARIES = ./macos-$(ARCH)
|
||||||
|
|
||||||
raylibfolder = ./raylib
|
raylib_folder = ./raylib
|
||||||
unityfolder = ./unity
|
unityfolder = ./unity
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@ -43,4 +43,4 @@ test: input.o game.o unit_tests.c $(BINARIES)/libunity.a
|
|||||||
# Clean
|
# Clean
|
||||||
# --------------------------
|
# --------------------------
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o wordsalad $(TEST_BIN)
|
rm -f *.o wordsalad
|
||||||
|
@ -101,35 +101,6 @@ void test_createWordSalad_too_small(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_createWordSalad_allWordsPlaced() {
|
|
||||||
char words[3][MAX_WORD_LEN] = {"CAT", "DOG", "MOUSE"};
|
|
||||||
char saladHoriz[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
||||||
char saladVert[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
||||||
|
|
||||||
int placed = createWordSalad(saladHoriz, 20, words, 3);
|
|
||||||
for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++)
|
|
||||||
{
|
|
||||||
saladVert[j][i] = saladHoriz[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++) {
|
|
||||||
const char* word = words[i];
|
|
||||||
int wordFound = 0;
|
|
||||||
for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++)
|
|
||||||
{
|
|
||||||
const char* row = saladHoriz[j];
|
|
||||||
const char* col = saladVert[j];
|
|
||||||
wordFound |= strstr(row, word) || strstr(col, word);
|
|
||||||
}
|
|
||||||
TEST_ASSERT_TRUE_MESSAGE(wordFound, "Not all words were placed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(3, placed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Test Setup und TearDown Funktionen ----------
|
// ---------- Test Setup und TearDown Funktionen ----------
|
||||||
|
|
||||||
// Hier Setup- und TearDown-Funktionen definieren,
|
// Hier Setup- und TearDown-Funktionen definieren,
|
||||||
@ -164,7 +135,6 @@ int main(void) {
|
|||||||
RUN_TEST(test_readWords_empty_file);
|
RUN_TEST(test_readWords_empty_file);
|
||||||
RUN_TEST(test_createWordSalad_all_fit);
|
RUN_TEST(test_createWordSalad_all_fit);
|
||||||
RUN_TEST(test_createWordSalad_too_small);
|
RUN_TEST(test_createWordSalad_too_small);
|
||||||
RUN_TEST(test_createWordSalad_allWordsPlaced);
|
|
||||||
|
|
||||||
int result = UNITY_END(); // Test-Ergebnisse
|
int result = UNITY_END(); // Test-Ergebnisse
|
||||||
print_test_result(result);
|
print_test_result(result);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// Creates the word salad by placing words randomly and filling empty spaces
|
||||||
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||||
{
|
{
|
||||||
|
Printf("Hello World+1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the word salad to console
|
// Prints the word salad to console
|
||||||
|
BIN
Start_Windows/input.o
Normal file
BIN
Start_Windows/input.o
Normal file
Binary file not shown.
@ -12,7 +12,7 @@ int main(int argc, char *argv[])
|
|||||||
int exitCode = EXIT_SUCCESS;
|
int exitCode = EXIT_SUCCESS;
|
||||||
|
|
||||||
// Check if the correct number of arguments is provided
|
// Check if the correct number of arguments is provided
|
||||||
if(argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
|
||||||
exitCode = EXIT_FAILURE;
|
exitCode = EXIT_FAILURE;
|
||||||
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
FILE *file = fopen(argv[1], "r");
|
FILE *file = fopen(argv[1], "r");
|
||||||
|
|
||||||
if(file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
unsigned int placedWords = 0;
|
unsigned int placedWords = 0;
|
||||||
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
|
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN]; // 2D array to store the word salad
|
||||||
@ -40,7 +40,14 @@ int main(int argc, char *argv[])
|
|||||||
// Check if all words were successfully placed
|
// Check if all words were successfully placed
|
||||||
// Start the game if successful
|
// Start the game if successful
|
||||||
// error message if some words couldn't be placed
|
// error message if some words couldn't be placed
|
||||||
|
if (wordCount != placedWords)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %u out of %u were placed\n", placedWords, wordCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
startGame(wordSalad, SALAD_SIZE, words, placedWords, 800);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -101,35 +101,6 @@ void test_createWordSalad_too_small(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_createWordSalad_allWordsPlaced() {
|
|
||||||
char words[3][MAX_WORD_LEN] = {"CAT", "DOG", "MOUSE"};
|
|
||||||
char saladHoriz[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
||||||
char saladVert[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
||||||
|
|
||||||
int placed = createWordSalad(saladHoriz, 20, words, 3);
|
|
||||||
for(int i = 0; i < MAX_SEARCH_FIELD_LEN; i++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++)
|
|
||||||
{
|
|
||||||
saladVert[j][i] = saladHoriz[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++) {
|
|
||||||
const char* word = words[i];
|
|
||||||
int wordFound = 0;
|
|
||||||
for(int j = 0; j < MAX_SEARCH_FIELD_LEN; j++)
|
|
||||||
{
|
|
||||||
const char* row = saladHoriz[j];
|
|
||||||
const char* col = saladVert[j];
|
|
||||||
wordFound |= strstr(row, word) || strstr(col, word);
|
|
||||||
}
|
|
||||||
TEST_ASSERT_TRUE_MESSAGE(wordFound, "Not all words were placed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(3, placed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Test Setup und TearDown Funktionen ----------
|
// ---------- Test Setup und TearDown Funktionen ----------
|
||||||
|
|
||||||
// Hier Setup- und TearDown-Funktionen definieren,
|
// Hier Setup- und TearDown-Funktionen definieren,
|
||||||
@ -164,7 +135,6 @@ int main(void) {
|
|||||||
RUN_TEST(test_readWords_empty_file);
|
RUN_TEST(test_readWords_empty_file);
|
||||||
RUN_TEST(test_createWordSalad_all_fit);
|
RUN_TEST(test_createWordSalad_all_fit);
|
||||||
RUN_TEST(test_createWordSalad_too_small);
|
RUN_TEST(test_createWordSalad_too_small);
|
||||||
RUN_TEST(test_createWordSalad_allWordsPlaced);
|
|
||||||
|
|
||||||
int result = UNITY_END(); // Test-Ergebnisse
|
int result = UNITY_END(); // Test-Ergebnisse
|
||||||
print_test_result(result);
|
print_test_result(result);
|
||||||
|
BIN
Start_Windows/wordsalad_initial.exe
Normal file
BIN
Start_Windows/wordsalad_initial.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user