Skip to content

Commit

Permalink
Fix a bug in num_in_numbits.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Aug 1, 2019
1 parent 666d5ca commit 2d7ad50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion coverage/numbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def numbits_any_intersection(numbits1, numbits2):
def num_in_numbits(num, numbits):
"""Does the integer `num` appear in `numbits`?"""
nbyte, nbit = divmod(num, 8)
if nbyte > len(numbits):
if nbyte >= len(numbits):
return False
return bool(byte_to_int(numbits[nbyte]) & (1 << nbit))
3 changes: 2 additions & 1 deletion tests/test_numbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""Tests for coverage.numbits"""

from hypothesis import given, settings
from hypothesis import example, given, settings
from hypothesis.strategies import sets, integers

from coverage import env
Expand Down Expand Up @@ -52,6 +52,7 @@ def test_any_intersection(self, nums1, nums2):

@given(line_numbers, line_number_sets)
@settings(default_settings)
@example(152, {144})
def test_num_in_numbits(self, num, nums):
numbits = nums_to_numbits(nums)
is_in = num_in_numbits(num, numbits)
Expand Down

0 comments on commit 2d7ad50

Please sign in to comment.