Skip to content

Commit fafd0a5

Browse files
authored
Merge pull request #11051 from evedon/minimal-printf
Minimal printf addition
2 parents d27867e + d6b197a commit fafd0a5

File tree

14 files changed

+2561
-11
lines changed

14 files changed

+2561
-11
lines changed

TESTS/mbed_drivers/c_strings/main.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static char buffer[256] = {0};
2828
#define CLEAN_BUFFER memset(::buffer, 0x00, sizeof(::buffer))
2929
#define NEGATIVE_INTEGERS -32768,-3214,-999,-100,-1,0,-1,-4231,-999,-4123,-32760,-99999
3030
#define POSITIVE_INTEGERS 32768,3214,999,100,1,0,1,4231,999,4123,32760,99999
31-
#define FLOATS 0.002,0.92430,15.91320,791.77368,6208.2,25719.4952,426815.982588,6429271.046,42468024.93,212006462.910
31+
#define FLOATS 0.002,0.92430,15.91320,791.77368,6208.2,25719.4952,426815.982588,6429271.046,42468024.93,212006462.910,6579.048
3232

3333
using namespace utest::v1;
3434

@@ -47,7 +47,7 @@ void test_case_c_string_u_d()
4747
TEST_ASSERT_EQUAL_STRING("32768 3214 999 100 1 0 1 4231 999 4123 32760 99999", buffer);
4848
}
4949

50-
void test_case_c_string_x_E()
50+
void test_case_c_string_x_X()
5151
{
5252
CLEAN_BUFFER;
5353
sprintf(buffer, "%x %X %x %X %x %X %x %X %x %X %x %X", POSITIVE_INTEGERS);
@@ -57,22 +57,22 @@ void test_case_c_string_x_E()
5757
void test_case_c_string_f_f()
5858
{
5959
CLEAN_BUFFER;
60-
sprintf(buffer, "%f %f %f %f %f %f %f %f %f %f", FLOATS);
61-
TEST_ASSERT_EQUAL_STRING("0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000", buffer);
60+
sprintf(buffer, "%f %f %f %f %f %f %f %f %f %f %f", FLOATS);
61+
TEST_ASSERT_EQUAL_STRING("0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000 6579.048000", buffer);
6262
}
6363

6464
void test_case_c_string_g_g()
6565
{
6666
CLEAN_BUFFER;
67-
sprintf(buffer, "%g %g %g %g %g %g %g %g %g %g", FLOATS);
68-
TEST_ASSERT_EQUAL_STRING("0.002 0.9243 15.9132 791.774 6208.2 25719.5 426816 6.42927e+06 4.2468e+07 2.12006e+08", buffer);
67+
sprintf(buffer, "%g %g %g %g %g %g %g %g %g %g %g", FLOATS);
68+
TEST_ASSERT_EQUAL_STRING("0.002 0.9243 15.9132 791.774 6208.2 25719.5 426816 6.42927e+06 4.2468e+07 2.12006e+08 6579.05", buffer);
6969
}
7070

7171
void test_case_c_string_e_E()
7272
{
7373
CLEAN_BUFFER;
74-
sprintf(buffer, "%e %E %e %E %e %E %e %E %e %E", FLOATS);
75-
TEST_ASSERT_EQUAL_STRING("2.000000e-03 9.243000E-01 1.591320e+01 7.917737E+02 6.208200e+03 2.571950E+04 4.268160e+05 6.429271E+06 4.246802e+07 2.120065E+08", buffer);
74+
sprintf(buffer, "%e %E %e %E %e %E %e %E %e %E %e", FLOATS);
75+
TEST_ASSERT_EQUAL_STRING("2.000000e-03 9.243000E-01 1.591320e+01 7.917737E+02 6.208200e+03 2.571950E+04 4.268160e+05 6.429271E+06 4.246802e+07 2.120065E+08 6.579048e+03", buffer);
7676
}
7777

7878
void test_case_c_string_strtok()
@@ -112,10 +112,12 @@ Case cases[] = {
112112
Case("C strings: strpbrk", test_case_c_string_strpbrk, greentea_failure_handler),
113113
Case("C strings: %i %d integer formatting", test_case_c_string_i_d, greentea_failure_handler),
114114
Case("C strings: %u %d integer formatting", test_case_c_string_u_d, greentea_failure_handler),
115-
Case("C strings: %x %E integer formatting", test_case_c_string_x_E, greentea_failure_handler),
115+
Case("C strings: %x %E integer formatting", test_case_c_string_x_X, greentea_failure_handler),
116116
Case("C strings: %f %f float formatting", test_case_c_string_f_f, greentea_failure_handler),
117+
#ifndef MBED_MINIMAL_PRINTF
117118
Case("C strings: %e %E float formatting", test_case_c_string_e_E, greentea_failure_handler),
118119
Case("C strings: %g %g float formatting", test_case_c_string_g_g, greentea_failure_handler),
120+
#endif
119121
};
120122

121123
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Description
2+
3+
This document describes how to run minimal-printf tests.
4+
5+
## Running tests
6+
7+
You can use the following command to run tests:
8+
9+
`mbed test -m K64F -t GCC_ARM -n *printf* -v -c`
10+
11+
Do not use --profile minimal-printf so minimal-printf is not compared with itself.

0 commit comments

Comments
 (0)