Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage for cryptomath #281

Merged
merged 4 commits into from
Jun 28, 2018
Merged

Test coverage for cryptomath #281

merged 4 commits into from
Jun 28, 2018

Conversation

tomato42
Copy link
Member

@tomato42 tomato42 commented Jun 27, 2018

Increase test coverage for cryptomath.py module, remove dead code


This change is Reviewable

@tomato42 tomato42 added the maintenance issues related to project maintenance, CI, documentation, etc. label Jun 27, 2018
@tomato42 tomato42 self-assigned this Jun 27, 2018
@tomato42 tomato42 requested a review from Jakuje June 28, 2018 10:52
Copy link
Collaborator

@Jakuje Jakuje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the comments inline, the change looks good.

@@ -194,6 +194,16 @@ def test_numBits(self, number):
def test_numBytes(self, number):
self.assertEqual(numBytes(number), self.num_bytes(number))


class TestPowMod(unittest.TestCase):
def test_with_small_numerts(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numerts looks like a typo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed it is, fixed

@@ -253,8 +253,7 @@ def numBytes(n):
# **************************************************************************

def getRandomNumber(low, high):
if low >= high:
raise AssertionError()
assert low <= high
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say low < high to preserve the same semantics. Does it make sense to generate random, where low == high? If so, the change in semantics should be reflected in the commit message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixed

don't rise the assert directly, makes the exception more readable
and code coverage happy
the negative power is not used anywhere in the code and gmpy does
not actually support it either so remove this code
Copy link
Collaborator

@Jakuje Jakuje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now

@tomato42
Copy link
Member Author

@Jakuje thanks for the review!

@tomato42 tomato42 merged commit ad4904f into master Jun 28, 2018
@tomato42 tomato42 deleted the test_cov_for_cryptomath branch June 28, 2018 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance issues related to project maintenance, CI, documentation, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants