Skip to content

Commit

Permalink
Improved the putchar unicode test
Browse files Browse the repository at this point in the history
  • Loading branch information
alelievr committed Nov 11, 2020
1 parent 58eb067 commit 0fb2f59
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/test_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -6809,24 +6809,38 @@ void test_ft_putchar_ascii(void *ptr) {
);
}

// Here's a famous japanese Haiku! It's good for your culture :)
wchar_t* haiku_0 = L"古池や蛙飛び込む水の音\
ふるいけやかわずとびこむみずのおと";

void test_ft_putchar_unicode(void *ptr) {
typeof(putchar) *ft_putchar = ptr;
SET_EXPLANATION("your putchar does not work with unicode");

SANDBOX_RAISE(
char buff[10];
char buff2[10];
int c = L'ø';
int len = 0;
putwchart(c, &len, buff2);
buff2[len] = 0;
STDOUT_TO_BUFF;
ft_putchar(c);
GET_STDOUT(buff, 10);
if (!strcmp(buff, buff2))
exit(TEST_SUCCESS);
SET_DIFF(buff, buff2);
exit(TEST_KO);

int i = 0;
while (haiku_0[i++])
{
wchar_t c = haiku_0[i];
putwchart(c, &len, buff2);
buff2[len] = 0;

STDOUT_TO_BUFF;
ft_putchar(c);
GET_STDOUT(buff, 10);

if (strcmp(buff, buff2))
{
SET_DIFF(buff2, buff);
exit(TEST_KO);
}
}
exit(TEST_SUCCESS);

);
(void)ft_putchar;
}
Expand Down

0 comments on commit 0fb2f59

Please sign in to comment.