@@ -404,6 +404,21 @@ static control_t test_printf_x(const size_t call_count)
404404 return CaseNext;
405405}
406406
407+ static control_t test_printf_percent (const size_t call_count)
408+ {
409+ int result_baseline;
410+ int result_minimal;
411+ int result_file;
412+
413+ result_minimal = mbed_printf (" %% \r\n " );
414+ result_file = mbed_fprintf (stderr, " %% \r\n " );
415+ result_baseline = printf (" %% \r\n " );
416+ TEST_ASSERT_EQUAL_INT (result_baseline, result_minimal);
417+ TEST_ASSERT_EQUAL_INT (result_baseline, result_file);
418+
419+ return CaseNext;
420+ }
421+
407422/* *****************************************************************************/
408423/* */
409424/* SNPRINTF */
@@ -721,6 +736,34 @@ static control_t test_snprintf_x(const size_t call_count)
721736 return CaseNext;
722737}
723738
739+ static control_t test_snprintf_percent (const size_t call_count)
740+ {
741+ char buffer_baseline[100 ];
742+ char buffer_minimal[100 ];
743+ int result_baseline;
744+ int result_minimal;
745+
746+ result_minimal = mbed_snprintf (buffer_minimal, sizeof (buffer_minimal), " %% \r\n " );
747+ result_baseline = snprintf (buffer_baseline, sizeof (buffer_baseline), " %% \r\n " );
748+ TEST_ASSERT_EQUAL_STRING (buffer_baseline, buffer_minimal);
749+ TEST_ASSERT_EQUAL_INT (result_baseline, result_minimal);
750+
751+ return CaseNext;
752+ }
753+
754+ static control_t test_snprintf_unsupported_specifier (const size_t call_count)
755+ {
756+ char buffer_minimal[100 ];
757+
758+ TEST_ASSERT_NOT_EQUAL (
759+ 0 ,
760+ mbed_snprintf (buffer_minimal, sizeof (buffer_minimal), " %a \r\n " , 5 )
761+ );
762+ TEST_ASSERT_EQUAL_STRING (" %a \r\n " , buffer_minimal);
763+
764+ return CaseNext;
765+ }
766+
724767#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
725768static control_t test_printf_f (const size_t call_count)
726769{
@@ -902,6 +945,9 @@ Case cases[] = {
902945 Case (" snprintf %u" , test_snprintf_u),
903946 Case (" printf %x" , test_printf_x),
904947 Case (" snprintf %x" , test_snprintf_x),
948+ Case (" printf %%" , test_printf_percent),
949+ Case (" snprintf %%" , test_snprintf_percent),
950+ Case (" snprintf unsupported specifier" , test_snprintf_unsupported_specifier),
905951#if MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT
906952 Case (" printf %f" , test_printf_f),
907953 Case (" snprintf %f" , test_snprintf_f),
0 commit comments