/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* test_strtok.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/26 11:24:49 by bgoulard #+# #+# */ /* Updated: 2024/06/25 21:43:49 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_string.h" int test_strtok(void) { char test[50]; char lorem[30]; lorem[0] = '\0'; test[0] = '\0'; ft_strlcpy(lorem, "Lorem ipsum dolor ", 30); ft_strlcpy(test, ":::path/to/file:::another/path::yet/:/another/path", 47); if (ft_strcmp(ft_strtok(lorem, " "), "Lorem") != 0 || ft_strcmp(ft_strtok(NULL, " "), "ipsum") != 0 || ft_strcmp(ft_strtok(NULL, " "), "dolor") != 0) return (1); if (ft_strcmp(ft_strtok(NULL, " "), "") != 0 || ft_strtok(NULL, " ")) return (2); if (ft_strcmp(ft_strtok(test, ":"), "path/to/file") != 0 || ft_strcmp(ft_strtok(NULL, ":"), "another/path") != 0) return (3); if (ft_strcmp(ft_strtok(NULL, ":/"), "yet") != 0) return (4); if (ft_strcmp(ft_strtok(NULL, ":/"), "another") != 0) return (5); return (0); }