aboutsummaryrefslogtreecommitdiff
path: root/test/ft_write_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_write_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_write_test.c')
-rw-r--r--test/ft_write_test.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/test/ft_write_test.c b/test/ft_write_test.c
index 1c14244..c44625e 100644
--- a/test/ft_write_test.c
+++ b/test/ft_write_test.c
@@ -4,21 +4,23 @@
static int ft_write_pipe[2];
static char buf[FT_WRITE_BUF_SIZE];
+static unsigned long write_ret;
static int ret;
-#define FT_WRITE_EXPECT(str) do { \
- if (pipe(ft_write_pipe) < 0) \
- exit(EXIT_FAILURE); \
- fcntl(ft_write_pipe[0], F_SETFL, O_NONBLOCK); \
- ft_write(ft_write_pipe[1], str, strlen(str)); \
- ret = read(ft_write_pipe[0], buf, FT_WRITE_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_write_pipe[1]); \
- close(ft_write_pipe[0]); \
+#define FT_WRITE_EXPECT(str) do { \
+ if (pipe(ft_write_pipe) < 0) \
+ exit(EXIT_FAILURE); \
+ fcntl(ft_write_pipe[0], F_SETFL, O_NONBLOCK); \
+ write_ret = ft_write(ft_write_pipe[1], str, strlen(str)); \
+ ret = read(ft_write_pipe[0], buf, FT_WRITE_BUF_SIZE); \
+ buf[ret] = '\0'; \
+ if (strcmp(buf, str) != 0 || write_ret != strlen(str)) \
+ printf("KO: [COMPARE]: %s: expected: %lu \"%s\" got: %lu \"%s\"\n", \
+ test_name, strlen(str), str, write_ret, buf); \
+ else \
+ print_ok(); \
+ close(ft_write_pipe[1]); \
+ close(ft_write_pipe[0]); \
} while (0);
void