some upgrades to tests
This commit is contained in:
parent
d4da57d77b
commit
5d2cf7f9c7
@ -2,10 +2,48 @@
|
|||||||
#define TESTS_H
|
#define TESTS_H
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define TEST_SOURCE "HeLlo world!\0It's a\tBEAUTIFUL\tday!"
|
#define TEST_SOURCE "HeLlo world!\0It's a\tBEAUTIFUL\tday!"
|
||||||
#define TEST_SOURCE_LENGHT 35
|
#define TEST_SOURCE_LENGHT 35
|
||||||
#define TEST_DESTINATION "GooDBye\0and thanks \tfor\rall the fish!"
|
#define TEST_DESTINATION "GooDBye\0and thanks _for\rall the fish!"
|
||||||
#define TEST_DESTINATION_LENGHT 38
|
#define TEST_DESTINATION_LENGHT 38
|
||||||
|
#define TEST_BUF_SIZE 100
|
||||||
|
#define TESTS_FUNC_NAME
|
||||||
|
#define TESTS_RETURN_PRINTF "%p"
|
||||||
|
#define TESTS_PRINT_BUFFERS(TESTS_FUNC_CASE) \
|
||||||
|
printf("original " TESTS_FUNC_CASE "\n"); \
|
||||||
|
dump(s1, TEST_SOURCE_LENGHT); \
|
||||||
|
dump(d1, TEST_DESTINATION_LENGHT); \
|
||||||
|
printf("replicated " TESTS_FUNC_CASE "\n"); \
|
||||||
|
dump(s2, TEST_SOURCE_LENGHT); \
|
||||||
|
dump(d2, TEST_DESTINATION_LENGHT);
|
||||||
|
|
||||||
|
#define TESTS_RESET_BUFFERS \
|
||||||
|
memcpy(d1, d, TEST_BUF_SIZE); \
|
||||||
|
memcpy(s1, s, TEST_BUF_SIZE); \
|
||||||
|
memcpy(d2, d, TEST_BUF_SIZE); \
|
||||||
|
memcpy(s2, s, TEST_BUF_SIZE);
|
||||||
|
#define TESTS_PRINT_BUFCMP(TESTS_FUNC_CASE) \
|
||||||
|
printf( \
|
||||||
|
"buffers comparison:\n " TESTS_FUNC_CASE ":\t%i\n ft_" TESTS_FUNC_CASE ":\t%i\n", \
|
||||||
|
bufcmp(s1, s2, TEST_SOURCE_LENGHT), \
|
||||||
|
bufcmp(d1, d2, TEST_DESTINATION_LENGHT) \
|
||||||
|
);
|
||||||
|
#define TESTS_PRINT_RETVALS printf("return values: orig: " TESTS_RETURN_PRINTF " ft: %p\n", r1, r2)
|
||||||
|
#define TESTS_SYNOPSIS(TESTS_FUNC_CASE) \
|
||||||
|
TESTS_PRINT_BUFFERS(TESTS_FUNC_CASE); \
|
||||||
|
TESTS_PRINT_BUFCMP(TESTS_FUNC_CASE); \
|
||||||
|
TESTS_PRINT_RETVALS; \
|
||||||
|
TESTS_RESET_BUFFERS;
|
||||||
|
#define TESTS_SEED(type) \
|
||||||
|
char s[TEST_BUF_SIZE] = TEST_SOURCE; \
|
||||||
|
char d[TEST_BUF_SIZE] = TEST_DESTINATION; \
|
||||||
|
type *r1; \
|
||||||
|
char s1[TEST_BUF_SIZE] = TEST_SOURCE; \
|
||||||
|
char d1[TEST_BUF_SIZE] = TEST_DESTINATION; \
|
||||||
|
type *r2; \
|
||||||
|
char s2[TEST_BUF_SIZE] = TEST_SOURCE; \
|
||||||
|
char d2[TEST_BUF_SIZE] = TEST_DESTINATION;
|
||||||
|
|
||||||
#define FG_WHT "\x1B[37m"
|
#define FG_WHT "\x1B[37m"
|
||||||
#define FG_MAG "\x1B[35m"
|
#define FG_MAG "\x1B[35m"
|
||||||
#define COLOR_RESET "\x1B[0m"
|
#define COLOR_RESET "\x1B[0m"
|
||||||
|
Loading…
Reference in New Issue
Block a user