Skip to content

Commit

Permalink
State-machine test for both implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezibenroc committed Aug 23, 2024
1 parent 11da4bb commit 50e0efa
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
from hypothesis import settings
from dataclasses import dataclass
from pyroaring import BitMap, BitMap64
from test64 import hyp_collection, uint64

BitMapClass = BitMap64
from test import hyp_collection, uint32, uint64, is_32_bits

if is_32_bits:
BitMapClass = BitMap
int_class = uint32
large_val = 2**30
else:
BitMapClass = BitMap64
int_class = uint64
large_val = 2**40

@dataclass
class Collection:
test: BitMap
test: BitMapClass
ref: set[int]

def check(self):
Expand All @@ -35,13 +41,13 @@ def init_collection(self, val):
def copy(self, col):
return Collection(test=BitMapClass(col.test), ref=set(col.ref))

@rule(col=collections, val=uint64)
@rule(col=collections, val=int_class)
def add_elt(self, col, val):
col.test.add(val)
col.ref.add(val)
col.check()

@rule(col=collections, val=uint64)
@rule(col=collections, val=int_class)
def remove_elt(self, col, val):
col.test.discard(val)
col.ref.discard(val)
Expand Down Expand Up @@ -90,7 +96,7 @@ def symmetric_difference_inplace(self, col1, col2):
@rule(
target=collections,
col=collections,
start=st.integers(min_value=0, max_value=2**40),
start=st.integers(min_value=0, max_value=large_val),
size=st.integers(min_value=0, max_value=2**18),
)
def flip(self, col, start, size):
Expand All @@ -101,7 +107,7 @@ def flip(self, col, start, size):

@rule(
col=collections,
start=st.integers(min_value=0, max_value=2**40),
start=st.integers(min_value=0, max_value=large_val),
size=st.integers(min_value=0, max_value=2**18),
)
def flip_inplace(self, col, start, size):
Expand Down

0 comments on commit 50e0efa

Please sign in to comment.