summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorRami Ali <flowergrass@users.noreply.github.com>2017-03-14 17:58:43 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-14 18:27:29 +1100
commit77cbd173df449e8e6eb79cba75b341f1721be377 (patch)
tree610fce8ddbd1ad2085707169303cc4f23e0f563e /unix
parent4e86ca398f64ceb0351414fd91408fc8f9494907 (diff)
downloadmicropython-77cbd173df449e8e6eb79cba75b341f1721be377.tar.gz
micropython-77cbd173df449e8e6eb79cba75b341f1721be377.zip
tests: Improve binary.c test coverage.
Diffstat (limited to 'unix')
-rw-r--r--unix/coverage.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/unix/coverage.c b/unix/coverage.c
index 5b0c8d7a06..ca236c4303 100644
--- a/unix/coverage.c
+++ b/unix/coverage.c
@@ -10,6 +10,7 @@
#include "py/emit.h"
#include "py/formatfloat.h"
#include "py/stream.h"
+#include "py/binary.h"
#if defined(MICROPY_UNIX_COVERAGE)
@@ -278,6 +279,19 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf(&mp_plat_print, "%s\n", buf2);
}
+ // binary
+ {
+ mp_printf(&mp_plat_print, "# binary\n");
+
+ // call function with float and double typecodes
+ float far[1];
+ double dar[1];
+ mp_binary_set_val_array_from_int('f', far, 0, 123);
+ mp_printf(&mp_plat_print, "%.0f\n", (double)far[0]);
+ mp_binary_set_val_array_from_int('d', dar, 0, 456);
+ mp_printf(&mp_plat_print, "%.0lf\n", dar[0]);
+ }
+
mp_obj_streamtest_t *s = m_new_obj(mp_obj_streamtest_t);
s->base.type = &mp_type_stest_fileio;
s->buf = NULL;