diff --git a/doble.exe b/doble.exe index f8de930..2db1f8d 100644 Binary files a/doble.exe and b/doble.exe differ diff --git a/highscores.txt b/highscores.txt index 3fe3727..d3dc2cb 100644 --- a/highscores.txt +++ b/highscores.txt @@ -3,6 +3,7 @@ Regis;18924 player_name;9929 Kamto;7946 player_name;5987 +player_1;4989 Warren;4986 player_name;4983 player1;3999 diff --git a/makefile b/makefile index 1f15f75..ec1390d 100644 --- a/makefile +++ b/makefile @@ -35,8 +35,20 @@ $(program_obj_filesobj_files): %.o: %.c # -------------------------- # Unit Tests # -------------------------- -unitTests: - echo "needs to be implemented" + +unitTests: test_numbers test_stack + +test_numbers: test_numbers.o stack.o bintree.o numbers.o + $(CC) $(FLAGS) $^ -o test_numbers + +test_numbers.o: test_numbers.c + $(CC) -c $(FLAGS) $< -o $@ + +test_stack: test_stack.o stack.o + $(CC) $(FLAGS) $^ -o test_stack + +test_stack.o: test_stack.c + $(CC) -c $(FLAGS) $< -o $@ # -------------------------- # Clean diff --git a/numbers.c b/numbers.c index bde8485..71541b9 100644 --- a/numbers.c +++ b/numbers.c @@ -15,6 +15,7 @@ // Returns NULL on errors. Use your implementation of the binary search tree to check for possible duplicates while // creating random numbers. unsigned int *createNumbers(unsigned int len) { + if (len < 2) return NULL; @@ -52,6 +53,7 @@ unsigned int *createNumbers(unsigned int len) { // Returns only the only number in numbers which is present twice. Returns zero on errors. unsigned int getDuplicate(const unsigned int numbers[], unsigned int len) { + if (!numbers || len < 2) return 0; // Kopie erstellen, damit Original nicht verändert wird diff --git a/test_numbers.exe b/test_numbers.exe index f648461..088659d 100644 Binary files a/test_numbers.exe and b/test_numbers.exe differ diff --git a/ test_stack.c b/test_stack.c similarity index 100% rename from test_stack.c rename to test_stack.c diff --git a/test_stack.exe b/test_stack.exe new file mode 100644 index 0000000..7f47629 Binary files /dev/null and b/test_stack.exe differ