Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
k11q committed Feb 18, 2023
1 parent cb67765 commit 1e2d760
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 105 deletions.
10 changes: 5 additions & 5 deletions mini-moul/tests/C00/ex00/ft_putchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int test1(void)
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " ft_putchar(\'c\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " GREEN CHECKMARK GREY " [1] ft_putchar(\'c\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
Expand Down Expand Up @@ -78,12 +78,12 @@ int test2(void)
const char *expected_output = "x";
if (strncmp(buffer, expected_output, 1) != 0)
{
printf(" " RED "[1] ft_putchar(\'x\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " RED "[2] ft_putchar(\'x\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " ft_putchar(\'x\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " GREEN CHECKMARK GREY " [2] ft_putchar(\'x\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
Expand Down Expand Up @@ -114,12 +114,12 @@ int test3(void)
const char *expected_output = "t";
if (strncmp(buffer, expected_output, 1) != 0)
{
printf(" " RED "[1] ft_putchar(\'t\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " RED "[3] ft_putchar(\'t\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " ft_putchar(\'t\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " GREEN CHECKMARK GREY " [3] ft_putchar(\'t\') Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
8 changes: 4 additions & 4 deletions mini-moul/tests/C00/ex04/ft_is_negative.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ int test2(void)
const char *expected_output = "N";
if (strncmp(buffer, expected_output, 1) != 0)
{
printf(" " RED "[1] ft_is_negative(8) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " RED "[2] ft_is_negative(8) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [1] ft_is_negative(8) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " GREEN CHECKMARK GREY " [2] ft_is_negative(8) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
Expand Down Expand Up @@ -112,12 +112,12 @@ int test3(void)
const char *expected_output = "N";
if (strncmp(buffer, expected_output, 1) != 0)
{
printf(" " RED "[1] ft_is_negative(-2147483648) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " RED "[3] ft_is_negative(-2147483648) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [1] ft_is_negative(-2147483648) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " GREEN CHECKMARK GREY " [3] ft_is_negative(-2147483648) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
8 changes: 4 additions & 4 deletions mini-moul/tests/C00/ex07/ft_putnbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ int test2(void)
const char *expected_output = "2008";
if (strncmp(buffer, expected_output, 4) != 0)
{
printf(" " RED "[1] ft_putnbr(2008) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " RED "[2] ft_putnbr(2008) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (-1);
}
else printf(" " GREEN CHECKMARK GREY " [1] ft_putnbr(2008) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
else printf(" " GREEN CHECKMARK GREY " [2] ft_putnbr(2008) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
Expand Down Expand Up @@ -109,11 +109,11 @@ int test3(void)
const char *expected_output = "-425";
if (strncmp(buffer, expected_output, 4) != 0)
{
printf(" " RED "[1] ft_putnbr(-425) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
printf(" " RED "[3] ft_putnbr(-425) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (-1);
}
else printf(" " GREEN CHECKMARK GREY " [1] ft_putnbr(-425) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
else printf(" " GREEN CHECKMARK GREY " [3] ft_putnbr(-425) Expected \"%s\", got \"%s\"\n"DEFAULT, expected_output, buffer);
remove("output.txt");
return (0);
}
42 changes: 41 additions & 1 deletion mini-moul/tests/C01/ex02/ft_swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include "../../../utils/constants.h"

int test1(void);
int test2(void);
int test3(void);

int main(void)
{
if (test1() != 0)
if (test1()+test2()+test3() != 0)
return (-1);
return (0);
}
Expand All @@ -31,4 +33,42 @@ int test1(void)
else
printf(" " GREEN CHECKMARK GREY " [1] ft_swap(x = 2, y = 3) output x = 3, y = 2\n" DEFAULT);
return (0);
}

int test2(void)
{
int x;
int y;

x = 9;
y = -4;
ft_swap(&x, &y);

if (x != -4 || y != 9)
{
printf(" " RED "[2] ft_swap(x = 9, y = -4) Expected x = -4, got %d. Expected y = 9, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [2] ft_swap(x = 9, y = -4) output x = -4, y = 9\n" DEFAULT);
return (0);
}

int test3(void)
{
int x;
int y;

x = -32;
y = 54;
ft_swap(&x, &y);

if (x != 54 || y != -32)
{
printf(" " RED "[3] ft_swap(x = -32, y = 54) Expected x = 54, got %d. Expected y = -32, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [3] ft_swap(x = -32, y = 54) output x = 54, y = -32\n" DEFAULT);
return (0);
}
52 changes: 49 additions & 3 deletions mini-moul/tests/C01/ex03/ft_div_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include "../../../utils/constants.h"

int test1(void);
int test2(void);
int test3(void);

int main(void)
{
if (test1() != 0)
if (test1()+test2()+test3() != 0)
return (-1);
return (0);
}
Expand All @@ -28,10 +30,54 @@ int test1(void)

if (x != 2 || y != 0)
{
printf(" " RED "[1] ft_div_mod(10, 5, &x, &y) Expected x = 3, got %d. Expected y = 2, got %d\n" DEFAULT, x, y);
printf(" " RED "[1] ft_div_mod(10, 5, &x, &y) Expected x = 2, got %d. Expected y = 0, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [1] ft_div_mod(10, 5, &x, &y) Expected x = 3, got %d. Expected y = 2, got %d\n" DEFAULT, x, y);
printf(" " GREEN CHECKMARK GREY " [1] ft_div_mod(10, 5, &x, &y) Expected x = 2, got %d. Expected y = 0, got %d\n" DEFAULT, x, y);
return (0);
}

int test2(void)
{
int a;
int b;
int x;
int y;

a = 25;
b = 6;
ft_div_mod(a, b, &x, &y);


if (x != 4 || y != 1)
{
printf(" " RED "[2] ft_div_mod(25, 6, &x, &y) Expected x = 4, got %d. Expected y = 1, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [2] ft_div_mod(25, 6, &x, &y) Expected x = 4, got %d. Expected y = 1, got %d\n" DEFAULT, x, y);
return (0);
}

int test3(void)
{
int a;
int b;
int x;
int y;

a = 47;
b = 8;
ft_div_mod(a, b, &x, &y);


if (x != 5 || y != 7)
{
printf(" " RED "[3] ft_div_mod(47, 8, &x, &y) Expected x = 5, got %d. Expected y = 7, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [3] ft_div_mod(47, 8, &x, &y) Expected x = 5, got %d. Expected y = 7, got %d\n" DEFAULT, x, y);
return (0);
}
46 changes: 43 additions & 3 deletions mini-moul/tests/C01/ex04/ft_ultimate_div_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include "../../../utils/constants.h"

int test1(void);
int test2(void);
int test3(void);

int main(void)
{
if (test1() != 0)
if (test1()+test2()+test3() != 0)
return (-1);
return (0);
}
Expand All @@ -25,10 +27,48 @@ int test1(void)

if (x != 5 || y != 0)
{
printf(" " RED "[1] ft_ultimate_div_mod(x = 15, y = 3) Expected x = 3, got %d. Expected y = 2, got %d\n" DEFAULT, x, y);
printf(" " RED "[1] ft_ultimate_div_mod(x = 15, y = 3) Expected x = 5, got %d. Expected y = 0, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [1] ft_ultimate_div_mod(x = 15, y = 3) Expected x = 3, got %d. Expected y = 2, got %d\n" DEFAULT, x, y);
printf(" " GREEN CHECKMARK GREY " [1] ft_ultimate_div_mod(x = 15, y = 3) Expected x = 5, got %d. Expected y = 0, got %d\n" DEFAULT, x, y);
return (0);
}

int test2(void)
{
int x;
int y;

x = 23;
y = 5;
ft_ultimate_div_mod(&x, &y);

if (x != 4 || y != 3)
{
printf(" " RED "[2] ft_ultimate_div_mod(x = 23, y = 5) Expected x = 4, got %d. Expected y = 3, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [2] ft_ultimate_div_mod(x = 23, y = 5) Expected x = 4, got %d. Expected y = 3, got %d\n" DEFAULT, x, y);
return (0);
}

int test3(void)
{
int x;
int y;

x = 32;
y = 5;
ft_ultimate_div_mod(&x, &y);

if (x != 6 || y != 2)
{
printf(" " RED "[3] ft_ultimate_div_mod(x = 32, y = 5) Expected x = 6, got %d. Expected y = 2, got %d\n" DEFAULT, x, y);
return (-1);
}
else
printf(" " GREEN CHECKMARK GREY " [3] ft_ultimate_div_mod(x = 32, y = 5) Expected x = 6, got %d. Expected y = 2, got %d\n" DEFAULT, x, y);
return (0);
}
Loading

0 comments on commit 1e2d760

Please sign in to comment.