Skip to content

Commit

Permalink
Merge pull request #276 from FppEpitech/test/implement-test-about-server
Browse files Browse the repository at this point in the history
Test/implement test about server
  • Loading branch information
AxelF44 authored Jun 23, 2024
2 parents b50be26 + 6a07490 commit 6c29b02
Show file tree
Hide file tree
Showing 8 changed files with 1,700 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ fclean:

tests_run:
@make tests_run -C server
@make tests_run -C ai
@make tests_run -C gui
@make tests_run -C ai

zappy_gui:
@make -C gui
Expand Down
2 changes: 2 additions & 0 deletions server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ TEST_FILES = list/list_test.c \
gui/commands/tests_sst.c \
gui/commands/tests_suc.c \
gui/commands/tests_tna.c \
ai/test_broadcast_command.c \
ai/test_eject_command.c \

OBJ = $(SRC:.c=.o)
MAIN_OBJ = $(MAIN:.c=.o)
Expand Down
11 changes: 11 additions & 0 deletions server/src/parsing/parse_height.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
#include <string.h>
#include <stdbool.h>

static int check_size(int result)
{
if (result < 10 || result > 30) {
dprintf(2, "Value must be between 10 and 30\n");
return CODE_ERROR_INVALID_ARG;
}
return CODE_SUCCESS;
}

int parse_height(char **arg, int *pos, parsing_t *parsing)
{
int result = 0;
Expand All @@ -31,6 +40,8 @@ int parse_height(char **arg, int *pos, parsing_t *parsing)
return CODE_ERROR_INVALID_ARG;
}
(*pos) += 2;
if (check_size(result) == CODE_ERROR_INVALID_ARG)
return CODE_ERROR_INVALID_ARG;
parsing->height = result;
return CODE_SUCCESS;
}
11 changes: 11 additions & 0 deletions server/src/parsing/parse_width.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
#include <string.h>
#include <stdbool.h>

static int check_size(int result)
{
if (result < 10 || result > 30) {
dprintf(2, "Value must be between 10 and 30\n");
return CODE_ERROR_INVALID_ARG;
}
return CODE_SUCCESS;
}

int parse_width(char **arg, int *pos, parsing_t *parsing)
{
int result = 0;
Expand All @@ -31,6 +40,8 @@ int parse_width(char **arg, int *pos, parsing_t *parsing)
return CODE_ERROR_INVALID_ARG;
}
(*pos) += 2;
if (check_size(result) == CODE_ERROR_INVALID_ARG)
return CODE_ERROR_INVALID_ARG;
parsing->width = result;
return CODE_SUCCESS;
}
Loading

0 comments on commit 6c29b02

Please sign in to comment.