Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
90e23c47
Commit
90e23c47
authored
Nov 20, 2006
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add extra SHA tests
parent
0e64202f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
Lib/test/test_sha.py
Lib/test/test_sha.py
+18
-1
No files found.
Lib/test/test_sha.py
View file @
90e23c47
...
...
@@ -11,9 +11,23 @@ from test import test_support
class
SHATestCase
(
unittest
.
TestCase
):
def
check
(
self
,
data
,
digest
):
computed
=
sha
.
new
(
data
).
hexdigest
()
# Check digest matches the expected value
obj
=
sha
.
new
(
data
)
computed
=
obj
.
hexdigest
()
self
.
assert_
(
computed
==
digest
)
# Verify that the value doesn't change between two consecutive
# digest operations.
computed_again
=
obj
.
hexdigest
()
self
.
assert_
(
computed
==
computed_again
)
# Check hexdigest() output matches digest()'s output
digest
=
obj
.
digest
()
hexd
=
""
for
c
in
digest
:
hexd
+=
'%02x'
%
ord
(
c
)
self
.
assert_
(
computed
==
hexd
)
def
test_case_1
(
self
):
self
.
check
(
"abc"
,
"a9993e364706816aba3e25717850c26c9cd0d89d"
)
...
...
@@ -26,6 +40,9 @@ class SHATestCase(unittest.TestCase):
self
.
check
(
"a"
*
1000000
,
"34aa973cd4c4daa4f61eeb2bdbad27316534016f"
)
def
test_case_4
(
self
):
self
.
check
(
chr
(
0xAA
)
*
80
,
'4ca0ef38f1794b28a8f8ee110ee79d48ce13be25'
)
def
test_main
():
test_support
.
run_unittest
(
SHATestCase
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment