Skip to content

Commit 77cbd17

Browse files
flowergrassdpgeorge
authored andcommitted
tests: Improve binary.c test coverage.
1 parent 4e86ca3 commit 77cbd17

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/unix/extra_coverage.py.exp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Warning: test
4343
?
4444
+1e+00
4545
+1e+00
46+
# binary
47+
122
48+
456
4649
0123456789 b'0123456789'
4750
7300
4851
7300

unix/coverage.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "py/emit.h"
1111
#include "py/formatfloat.h"
1212
#include "py/stream.h"
13+
#include "py/binary.h"
1314

1415
#if defined(MICROPY_UNIX_COVERAGE)
1516

@@ -278,6 +279,19 @@ STATIC mp_obj_t extra_coverage(void) {
278279
mp_printf(&mp_plat_print, "%s\n", buf2);
279280
}
280281

282+
// binary
283+
{
284+
mp_printf(&mp_plat_print, "# binary\n");
285+
286+
// call function with float and double typecodes
287+
float far[1];
288+
double dar[1];
289+
mp_binary_set_val_array_from_int('f', far, 0, 123);
290+
mp_printf(&mp_plat_print, "%.0f\n", (double)far[0]);
291+
mp_binary_set_val_array_from_int('d', dar, 0, 456);
292+
mp_printf(&mp_plat_print, "%.0lf\n", dar[0]);
293+
}
294+
281295
mp_obj_streamtest_t *s = m_new_obj(mp_obj_streamtest_t);
282296
s->base.type = &mp_type_stest_fileio;
283297
s->buf = NULL;

0 commit comments

Comments
 (0)