Skip to content

Commit f601390

Browse files
committed
unix: Add some extra coverage tests for vstr and attrtuple.
1 parent 7bab32e commit f601390

2 files changed

Lines changed: 50 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,7 +1,17 @@
1+
# vstr
2+
tests
3+
sts
4+
5+
test
6+
tes
7+
larg
8+
# repl
19
ame__
210

311
__name__ path argv version
412
version_info implementation platform byteorder
513
maxsize exit stdin stdout
614
stderr exc_info print_exception
715
ementation
16+
# attrtuple
17+
(start=1, stop=2, step=3)

unix/coverage.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,38 @@
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+
// vstr
12+
{
13+
printf("# vstr\n");
14+
vstr_t *vstr = vstr_new_size(16);
15+
vstr_hint_size(vstr, 32);
16+
vstr_add_str(vstr, "ts");
17+
vstr_ins_byte(vstr, 1, 'e');
18+
vstr_ins_char(vstr, 3, 't');
19+
vstr_ins_char(vstr, 10, 's');
20+
printf("%.*s\n", (int)vstr->len, vstr->buf);
21+
22+
vstr_cut_head_bytes(vstr, 2);
23+
printf("%.*s\n", (int)vstr->len, vstr->buf);
24+
25+
vstr_cut_tail_bytes(vstr, 10);
26+
printf("%.*s\n", (int)vstr->len, vstr->buf);
27+
28+
vstr_printf(vstr, "t%cst", 'e');
29+
printf("%.*s\n", (int)vstr->len, vstr->buf);
30+
31+
vstr_cut_out_bytes(vstr, 3, 10);
32+
printf("%.*s\n", (int)vstr->len, vstr->buf);
33+
34+
VSTR_FIXED(fix, 4);
35+
vstr_add_str(&fix, "large");
36+
printf("%.*s\n", (int)fix.len, fix.buf);
37+
}
38+
1139
// repl autocomplete
1240
{
41+
printf("# repl\n");
42+
1343
const char *str;
1444
mp_uint_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
1545
printf("%.*s\n", (int)len, str);
@@ -20,6 +50,16 @@ STATIC mp_obj_t extra_coverage(void) {
2050
printf("%.*s\n", (int)len, str);
2151
}
2252

53+
// attrtuple
54+
{
55+
printf("# attrtuple\n");
56+
57+
static const qstr fields[] = {MP_QSTR_start, MP_QSTR_stop, MP_QSTR_step};
58+
static const mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(1), MP_OBJ_NEW_SMALL_INT(2), MP_OBJ_NEW_SMALL_INT(3)};
59+
mp_obj_print_helper(&mp_plat_print, mp_obj_new_attrtuple(fields, 3, items), PRINT_REPR);
60+
printf("\n");
61+
}
62+
2363
return mp_const_none;
2464
}
2565
MP_DEFINE_CONST_FUN_OBJ_0(extra_coverage_obj, extra_coverage);

0 commit comments

Comments
 (0)