aboutsummaryrefslogtreecommitdiff
path: root/test/ft_read_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/ft_read_test.c')
-rw-r--r--test/ft_read_test.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/test/ft_read_test.c b/test/ft_read_test.c
index 50a85bd..5b29803 100644
--- a/test/ft_read_test.c
+++ b/test/ft_read_test.c
@@ -6,19 +6,20 @@ static int ft_read_pipe[2];
static char buf[FT_READ_BUF_SIZE];
static int ret;
-#define FT_READ_EXPECT(str) do { \
- if (pipe(ft_read_pipe) < 0) \
- exit(EXIT_FAILURE); \
- fcntl(ft_read_pipe[0], F_SETFL, O_NONBLOCK); \
- write(ft_read_pipe[1], str, strlen(str)); \
- ret = ft_read(ft_read_pipe[0], buf, FT_READ_BUF_SIZE); \
- buf[ret] = '\0'; \
- if (strcmp(buf, str) != 0) \
- printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\"\n", test_name, str, buf); \
- else \
- print_ok(); \
- close(ft_read_pipe[1]); \
- close(ft_read_pipe[0]); \
+#define FT_READ_EXPECT(str) do { \
+ if (pipe(ft_read_pipe) < 0) \
+ exit(EXIT_FAILURE); \
+ fcntl(ft_read_pipe[0], F_SETFL, O_NONBLOCK); \
+ write(ft_read_pipe[1], str, strlen(str)); \
+ ret = ft_read(ft_read_pipe[0], buf, strlen(str)); \
+ buf[ret] = '\0'; \
+ if (strcmp(buf, str) != 0 || ret != strlen(str)) \
+ printf("KO: [COMPARE]: %s: expected: %lu \"%s\" got: %d \"%s\"\n", \
+ test_name, strlen(str), str, ret, buf); \
+ else \
+ print_ok(); \
+ close(ft_read_pipe[1]); \
+ close(ft_read_pipe[0]); \
} while (0);
void