cacharle/ft_printf_test

tests ft_printf("%-5c", '\0') & ft_printf("{%3c}", 0)

ErnestoAvedillo opened this issue · 4 comments

Hello
In my results when I execute the following code
in a single main my result is: printf("%-5c", '\0') --> " " (4 blanks)
in your code you get the following result: printf("%-5c", '\0') --> "" (No blanks)

The same for
in a simple main program I get: printf("{%3c}", 0)-->"{ }"(1 bracket & 2 blanks & 1 braket)
in your code you get the following result: printf("{%3c}", 0)-->"{ " (1 bracket & 2 blanks)

In my opinion, for any reason I can't explain, those results you get are not OK.

Will review first

Why did you close?

Just after sending the issue I thought I knew why is happening this to me, and I wanted to make a review before disturbing you.
Sorry for the inconvenience.

Hello
Finally I confirmed that is a problem while printing the result of the test when there is an error. The output i got is:

  • [OUTPUT] ft_printf("%-5c", '\0')
    expected: ""
    actual: " "

  • [OUTPUT] ft_printf("{%3c}", 0)
    expected: "{ "
    actual: "{ }"

With this message, I thought the expected was incorrect. (because the printf gives me the actual result).
The reason is:
When you print printf("{%3c}", 0) I suppose you do it in a string with result "{ \0}" (2 spaces) and then you print "{ " because there is a \0 in the middle of the string.
The same for printf("%-5c", '\0'). in this case the resulted string is "\0 " (4spaces) but you print "".

This gives the impression that your print is incorrect when it is not.
I would like to solve it by myself but, honestly, I don't know how to do it.
I will not reopen the issue. I just want to let you know about my conclusion.
Best Regards.