2023-11-30 19:05:07 +00:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* ex04.c :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2023/11/30 22:27:20 by achubuko #+# #+# */
|
2023-11-30 19:26:04 +00:00
|
|
|
/* Updated: 2023/11/30 23:24:57 by achubuko ### ########.fr */
|
2023-11-30 19:05:07 +00:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
#include <unity.h>
|
2023-11-30 19:26:04 +00:00
|
|
|
#include <string.h>
|
2023-11-30 19:05:07 +00:00
|
|
|
|
|
|
|
char *ft_strstr(char *str, char *to_find);
|
2023-11-30 19:26:04 +00:00
|
|
|
char *g_hs = "Hello_world";
|
|
|
|
char *g_needle = "Wo";
|
|
|
|
char *g_garbage = "zzzZz";
|
2023-11-30 19:05:07 +00:00
|
|
|
|
|
|
|
void setUp(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void tearDown(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-11-30 19:26:04 +00:00
|
|
|
void test_strstr_no_match(void)
|
|
|
|
{
|
|
|
|
char *r1;
|
|
|
|
char *r2;
|
|
|
|
|
|
|
|
r1 = strstr(g_hs, g_garbage);
|
|
|
|
r2 = ft_strstr(g_hs, g_garbage);
|
|
|
|
TEST_ASSERT_EQUAL_PTR(r1, r2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_strstr(void)
|
|
|
|
{
|
|
|
|
char *r1;
|
|
|
|
char *r2;
|
|
|
|
|
|
|
|
r1 = strstr(g_hs, g_needle);
|
|
|
|
r2 = ft_strstr(g_hs, g_needle);
|
|
|
|
TEST_ASSERT_EQUAL_PTR(r1, r2);
|
|
|
|
}
|
|
|
|
|
2023-11-30 19:05:07 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
UNITY_BEGIN();
|
2023-11-30 19:26:04 +00:00
|
|
|
RUN_TEST(test_strstr_no_match);
|
|
|
|
RUN_TEST(test_strstr);
|
2023-11-30 19:05:07 +00:00
|
|
|
return (UNITY_END());
|
|
|
|
}
|