ex04: create

This commit is contained in:
Aleksei Chubukov 2023-11-30 23:26:04 +04:00
parent c32240e07f
commit 18b889e75a
2 changed files with 30 additions and 2 deletions

View File

@ -6,12 +6,16 @@
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */ /* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/30 22:27:20 by achubuko #+# #+# */ /* Created: 2023/11/30 22:27:20 by achubuko #+# #+# */
/* Updated: 2023/11/30 22:53:40 by achubuko ### ########.fr */ /* Updated: 2023/11/30 23:24:57 by achubuko ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <unity.h> #include <unity.h>
#include <string.h>
char *ft_strstr(char *str, char *to_find); char *ft_strstr(char *str, char *to_find);
char *g_hs = "Hello_world";
char *g_needle = "Wo";
char *g_garbage = "zzzZz";
void setUp(void) void setUp(void)
{ {
@ -21,8 +25,30 @@ void tearDown(void)
{ {
} }
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);
}
int main(void) int main(void)
{ {
UNITY_BEGIN(); UNITY_BEGIN();
RUN_TEST(test_strstr_no_match);
RUN_TEST(test_strstr);
return (UNITY_END()); return (UNITY_END());
} }

4
r.bash
View File

@ -1,2 +1,4 @@
#!/bin/bash #!/bin/bash
T=build/"$1"; make $T && $T T=build/"$1"
norminette ../c*
make $T && $T