Skip to content

Commit a16715a

Browse files
committed
tests: Add special tests to test mp_printf function to improve coverage.
1 parent 9ede4dc commit a16715a

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

tests/unix/extra_coverage.py.exp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# mp_printf
2+
-123 +123 123
3+
-0123
4+
123
5+
1ABCDEF
6+
ab abc
7+
8+
false true
9+
(null)
10+
t
111
# vstr
212
tests
313
sts

unix/coverage.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88

99
// function to run extra tests for things that can't be checked by scripts
1010
STATIC mp_obj_t extra_coverage(void) {
11+
// mp_printf (used by ports that don't have a native printf)
12+
{
13+
printf("# mp_printf\n");
14+
mp_printf(&mp_plat_print, "%"); // nothing after percent
15+
mp_printf(&mp_plat_print, "%d %+d % d\n", -123, 123, 123); // sign
16+
mp_printf(&mp_plat_print, "%05d\n", -123); // negative number with zero padding
17+
mp_printf(&mp_plat_print, "%ld\n", 123); // long
18+
mp_printf(&mp_plat_print, "%X\n", 0x1abcdef); // capital hex
19+
mp_printf(&mp_plat_print, "%.2s %.3s\n", "abc", "abc"); // fixed string precision
20+
mp_printf(&mp_plat_print, "%.*s\n", -1, "abc"); // negative string precision
21+
mp_printf(&mp_plat_print, "%b %b\n", 0, 1); // bools
22+
mp_printf(&mp_plat_print, "%s\n", NULL); // null string
23+
mp_printf(&mp_plat_print, "%t\n"); // non-format char
24+
}
25+
1126
// vstr
1227
{
1328
printf("# vstr\n");

0 commit comments

Comments
 (0)