Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
58f38613
Commit
58f38613
authored
Sep 2, 2016
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
tests/unix/extra_coverage: Add test for str/bytes with invalid hash.
parent
5f3bda42
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/unix/extra_coverage.py
+8
-1
8 additions, 1 deletion
tests/unix/extra_coverage.py
tests/unix/extra_coverage.py.exp
+5
-0
5 additions, 0 deletions
tests/unix/extra_coverage.py.exp
unix/coverage.c
+8
-1
8 additions, 1 deletion
unix/coverage.c
with
21 additions
and
2 deletions
tests/unix/extra_coverage.py
+
8
−
1
View file @
58f38613
...
...
@@ -5,4 +5,11 @@ except NameError:
import
sys
sys
.
exit
()
extra_coverage
()
data
=
extra_coverage
()
# test hashing of str/bytes that have an invalid hash
print
(
data
)
print
(
hash
(
data
[
0
]))
print
(
hash
(
data
[
1
]))
print
(
hash
(
bytes
(
data
[
0
],
'
utf8
'
)))
print
(
hash
(
str
(
data
[
1
],
'
utf8
'
)))
This diff is collapsed.
Click to expand it.
tests/unix/extra_coverage.py.exp
+
5
−
0
View file @
58f38613
...
...
@@ -35,3 +35,8 @@ ementation
12345678
0
0
('0123456789', b'0123456789')
7300
7300
7300
7300
This diff is collapsed.
Click to expand it.
unix/coverage.c
+
8
−
1
View file @
58f38613
#include
<stdio.h>
#include
"py/obj.h"
#include
"py/objstr.h"
#include
"py/runtime.h"
#include
"py/repl.h"
#include
"py/mpz.h"
#if defined(MICROPY_UNIX_COVERAGE)
// str/bytes objects without a valid hash
STATIC
const
mp_obj_str_t
str_no_hash_obj
=
{{
&
mp_type_str
},
0
,
10
,
(
const
byte
*
)
"0123456789"
};
STATIC
const
mp_obj_str_t
bytes_no_hash_obj
=
{{
&
mp_type_bytes
},
0
,
10
,
(
const
byte
*
)
"0123456789"
};
// 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)
...
...
@@ -109,7 +114,9 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf
(
&
mp_plat_print
,
"%d
\n
"
,
mpz_as_uint_checked
(
&
mpz
,
&
value
));
}
return
mp_const_none
;
// return a tuple of data for testing on the Python side
mp_obj_t
items
[]
=
{(
mp_obj_t
)
&
str_no_hash_obj
,
(
mp_obj_t
)
&
bytes_no_hash_obj
};
return
mp_obj_new_tuple
(
MP_ARRAY_SIZE
(
items
),
items
);
}
MP_DEFINE_CONST_FUN_OBJ_0
(
extra_coverage_obj
,
extra_coverage
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment