aboutsummaryrefslogtreecommitdiff
path: root/test/ft_read_test.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-06 00:28:25 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-06 00:28:25 +0100
commit88f29720d2a09eaef81ad3646169d6bc19be8bfb (patch)
treef7bcea07a8a7e4076c1817609c4a60d7e8213066 /test/ft_read_test.c
parent1ab2fedd108b26c9624454a897e2c518aaff7d32 (diff)
downloadlibasm_test-88f29720d2a09eaef81ad3646169d6bc19be8bfb.tar.gz
libasm_test-88f29720d2a09eaef81ad3646169d6bc19be8bfb.tar.bz2
libasm_test-88f29720d2a09eaef81ad3646169d6bc19be8bfb.zip
Added ft_list_size and ft_list_push_front test
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