summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-05-28 14:25:07 +0000
committerDamien George <damien.p.george@gmail.com>2015-05-28 14:25:07 +0000
commita16715ac623dccd66b1a113af255811bf92286e8 (patch)
tree43d64aff1ccfca789bf945766dfc076ce35aabf3
parent9ede4dcfbb31a4adbd729466d72a1d10aa81b4fc (diff)
downloadmicropython-a16715ac623dccd66b1a113af255811bf92286e8.tar.gz
micropython-a16715ac623dccd66b1a113af255811bf92286e8.zip
tests: Add special tests to test mp_printf function to improve coverage.
-rw-r--r--tests/unix/extra_coverage.py.exp10
-rw-r--r--unix/coverage.c15
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 62debadcd0..651a47819c 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -1,3 +1,13 @@
+# mp_printf
+-123 +123 123
+-0123
+123
+1ABCDEF
+ab abc
+
+false true
+(null)
+t
# vstr
tests
sts
diff --git a/unix/coverage.c b/unix/coverage.c
index 757ebf1a2e..eabd0097d7 100644
--- a/unix/coverage.c
+++ b/unix/coverage.c
@@ -8,6 +8,21 @@
// function to run extra tests for things that can't be checked by scripts
STATIC mp_obj_t extra_coverage(void) {
+ // mp_printf (used by ports that don't have a native printf)
+ {
+ printf("# mp_printf\n");
+ mp_printf(&mp_plat_print, "%"); // nothing after percent
+ mp_printf(&mp_plat_print, "%d %+d % d\n", -123, 123, 123); // sign
+ mp_printf(&mp_plat_print, "%05d\n", -123); // negative number with zero padding
+ mp_printf(&mp_plat_print, "%ld\n", 123); // long
+ mp_printf(&mp_plat_print, "%X\n", 0x1abcdef); // capital hex
+ mp_printf(&mp_plat_print, "%.2s %.3s\n", "abc", "abc"); // fixed string precision
+ mp_printf(&mp_plat_print, "%.*s\n", -1, "abc"); // negative string precision
+ mp_printf(&mp_plat_print, "%b %b\n", 0, 1); // bools
+ mp_printf(&mp_plat_print, "%s\n", NULL); // null string
+ mp_printf(&mp_plat_print, "%t\n"); // non-format char
+ }
+
// vstr
{
printf("# vstr\n");