Hacker News new | ask | show | jobs
by s_gourichon 295 days ago
Nice. Comprehensive unit tests are indeed welcome. Even a simple test code that tests all features, flags combinations, etc, and outputs a log. It will make easy for anyone to run it and compare the logs.

I had a bug:

    u_printf( my_output_cb, NULL, "%d" NL, -42 );
prints:

--42

I may have found an explanation. In u_parse_format(), case 'i': calls u_itoa( value, buffer, 10, false ); which outputs minus sign.

Then if ( number ) does if ( sign ) { output_cb( '-', ctx ); chars_written++; } which outputs another minus sign.

2 comments

Thanks, I will review your PR, and I have to thank you very much for saving my time and correcting the error.
Also floats seem to "forget" the integer part, and also have two minus signs when negative.