static int	ft_test_strnew2(size_t size)
{
	int		res;
	char	*str;
	size_t	i;

	res = 0;
	i = 0;
	str = ft_strnew(size);
	memset(str, '1', size);
	while (i < (size + 1) && str)
	{
		if (str[i] == 1)
			++res;
		++i;
	}
	if (str)
	{
		ft_strdel(&str);
		if (str)
			++res;
	}
	printf("Test : %ld", size);
	ft_print_status(res);
	return (res);
}
示例#2
0
static int	ft_test_strlen2(const char *str)
{
	int	res;

	res = 0;
	printf("Test : \"%s\"", str);
	if (ft_strlen(str) != strlen(str))
		++res;
	ft_print_status(res);
	return (res);
}
static int	ft_test_memset2(char *str, char *str2, int n)
{
	int	res;

	res = 0;
	ft_memset(str, '{', n);
	memset(str2, '{', n);
	printf("After : \"%s\" , \"%s\"", str, str2);
	if (strcmp_bsd(str, str2))
		++res;
	ft_print_status(res);
	return (res);
}
示例#4
0
static int	ft_test_strdup2(const char *str)
{
	int		res;
	char	*cpy;
	char	*cpy2;

	res = 0;
	printf("Test : \"%s\"", str);
	cpy = ft_strdup(str);
	cpy2 = strdup(str);
	if (strcmp(cpy, cpy2))
		++res;
	ft_print_status(res);
	return (res);
}
示例#5
0
static int 	ft_test_strcmp2(char *str, char *str2)
{
	int	res;
	int	res2;
	int	res3;

	res = 0;
	res2 = ft_strcmp(str, str2);
	res3 = strcmp(str, str2);
	printf("Compare \"%s\" and \"%s\" { %d , %d }", str, str2, res2, res3);
	if (res2 != res3)
		++res;
	ft_print_status(res2 != res3);
	return (res);
}
示例#6
0
int	ft_test_isalpha2(char c)
{
	int	res;
	int	res2;
	int	res3;

	res = 0;
	res2 = ft_isalpha(c);
	res3 = isalpha(c);
	if (res2 != res3)
		++res;
	printf("Test : %c { %d - %d }", c, res2, res3);
	ft_print_status(res);
	return (res);
}
示例#7
0
int	ft_test_strchr2(char const *s, int c)
{
	int		res;
	char	*res2;
	char	*res3;

	res = 0;
	res2 = ft_strchr(s, c);
	res3 = strchr(s, c);
	if (res2 != res3)
		++res;
	printf("Test : \"%s\" { %p - %p }", s, res2, res3);
	ft_print_status(res);
	return (res);
}
static int	ft_test_atoi2(const char *str)
{
	int	res;
	int	res2;
	int	res3;

	res = 0;
	res2 = ft_atoi(str);
	res3 = atoi(str);
	if (res2 != res3)
		++res;
	printf("Test : \"%s\" { %d | %d }", str, res2, res3);
	ft_print_status(res);
	return (res);
}
示例#9
0
int	ft_test_toupper2(int c)
{
	int	res;
	int	res2;
	int	res3;

	res = 0;
	res2 = ft_toupper(c);
	res3 = toupper(c);
	if (res2 != res3)
		++res;
	printf("Test : %c { %c - %c }", (char)c, (char)res2, (char)res3);
	ft_print_status(res);
	return (res);
}
示例#10
0
static int	ft_test_strncmp2(char const *s1, char const *s2, int n)
{
	int	res;
	int	res2;
	int	res3;

	res = 0;
	res2 = ft_strncmp(s1, s2, n);
	res3 = strncmp(s1, s2, n);
	if (res2 != res3)
		++res;
	printf("Test : Compare \"%s\" and \"%s\" (%d) { %d - %d }", s1, s2, n, res2, res3);
	ft_print_status(res);
	return (res);
}
static int	ft_test_isascii2(const char c)
{
	int	res;
	int	res2;
	int	res3;

	res = 0;
	res2 = ft_isascii(c);
	res3 = isascii(c) || 0;
	if (res2 != res3)
		++res;
	printf("Test : \'%c\' (%d) { %d - %d }", c, c, res2, res3);
	ft_print_status(res);
	return (res);
}
static int	ft_test_memmove2(char *str, const char *src, size_t len)
{
	int		res;
	char	*src2;

	res = 0;
	src2 = strdup(src);
	printf("Test : \"%s\" and \"%s\" (%lu)", str, src, len);
	ft_memmove(str, src, len);
	memmove((src2 + (src - str)), src2, len);
	if (memcmp((src2 + (src - str)), str, len))
		++res;
	printf(" { \"%s\" | \"%s\" }", str, (src2 + (src - str)));
	ft_print_status(res);
  free(src2);
	return (res);
}
示例#13
0
static int	ft_test_bzero2(void *buf, size_t len)
{
	int		res;
	char	*tmp;

	res = 0;
	ft_bzero(buf, len);
	tmp = (char *)buf;
	while (len)
	{
		if (*tmp)
			++res;
		--len;
	}
	printf("Test");
	ft_print_status(res);
	return (res);
}
static int	ft_test_strsub2(char const *s1,
                            unsigned int start,
                            size_t len,
                            char const *str_final)
{
	int		res;
	char	*str;

	res = 0;
	str = ft_strsub(s1, start, len);
	if (str && strcmp_bsd(str, str_final))
		++res;
	else if (!str && len > 0)
		++res;
	printf("Test : Sub \"%s\" (%d, %ld) { \"%s\" }", s1, start, len, str);
	free(str);
	ft_print_status(res);
	return (res);
}
int	ft_test_lstiter(void)
{
	int		res;
	int		i1;
	int		i2;
	t_list	*elem;
	t_list	*elem2;
	int		*tmp1;
	int		*tmp2;

	res = 0;
	i1 = 150;
	i2 = -130;
	ft_print_begin("ft_lstiter");
	elem = (t_list*)malloc(sizeof(t_list));
	elem2 = (t_list*)malloc(sizeof(t_list));
	elem->next = elem2;
	elem->content = (void *)&i1;
	elem->content_size = elem2->content_size = sizeof(int);
	elem2->content = (void *)&i2;
	elem2->content_size = elem2->content_size = sizeof(int);
	elem2->next = NULL;;
	ft_lstiter(elem, ft_test_lstiter_iter);
	tmp1 = (int *) elem->content;
	tmp2 = (int *) elem2->content;
	if (*tmp1 != 151)
	{
		printf("*(elem->content) (%d) != (151)\n", *tmp1);
		res++;
	}
	else if (*tmp2 != -129)
	{
		printf("*(elem2->content) (%d) != (-129)\n", *tmp2);
		res++;
	}
	else
	{
		printf("Test passed function passed as argument was applied./n");
	}
	printf("Test");
	ft_print_status(res);
	return (ft_print_end(res));
}
示例#16
0
int	ft_test_putchar_fd2(char c)
{
	int		res;
	char	res2;
	int		fd;

	res = 0;
	fd = open("log.txt", O_WRONLY);
	ft_putchar_fd(c, fd);
	close(fd);
	fd = open("log.txt", O_RDONLY);
	read(fd, &res2, 1);
	close(fd);
	if (res2 != c)
		++res;
	printf("Test : '%c' { '%c' }", c, res2);
	ft_print_status(res);
	return (res);
}
static int	ft_test_memcpy2(void *dest, const void *src, size_t len)
{
	int			res;
	char		*tmp;
	const char	*tmp2;

	tmp = (char *)dest;
	tmp2 = (const char *)src;
	res = 0;
	printf("Test");
	ft_memcpy(dest, src, len);
	while (len)
	{
		if (*tmp != *tmp2)
			++res;
		--len;
	}
	ft_print_status(res);
	return (res);
}
static int	ft_test_strcpy2(char const *s1, const char *s2)
{
	int		res;
	char	*str2;
	char	*str1;

	res = 0;
	str2 = strdup(s1);
	str1 = strdup(s1);
	ft_strcpy(str2, s2);
	strcpy(str1, s2);
	if (strcmp_bsd(str1, str2))
		++res;
	printf("Test \"%s\" : { \"%s\" | \"%s\" }", s2, str2, str1);
	ft_print_status(res);

	free(str1);
	free(str2);
	return (res);
}
static int	ft_test_strcat2(char *s1, char const *s2, size_t len_buffer)
{
	int		res;
	char	*res2;
	char	*str2;

	res = 0;
	str2 = (char *)malloc(sizeof(char) * len_buffer);
	strcpy(str2, s1);
	res2 = ft_strcat(s1, s2);
	if (res2 != s1)
		++res;
	strcat(str2, s2);
	if (strcmp_bsd(str2, s1))
		++res;
	printf("Test : { \"%s\" }", s1);
	free(str2);
	ft_print_status(res);
	return (res);
}