-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from pganssle/othermod_example
Add tests for othermod
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from rustapi_module import othermod | ||
|
||
from hypothesis import given, assume | ||
from hypothesis import strategies as st | ||
|
||
INTEGER32_ST = st.integers(min_value=(-(2**31)), max_value=(2**31 - 1)) | ||
USIZE_ST = st.integers(min_value=othermod.USIZE_MIN, | ||
max_value=othermod.USIZE_MAX) | ||
|
||
@given(x=INTEGER32_ST) | ||
def test_double(x): | ||
expected = x*2 | ||
assume(-(2**31) <= expected <= (2**31 - 1)) | ||
assert othermod.double(x) == expected | ||
|
||
def test_modclass(): | ||
# Test that the repr of the class itself doesn't crash anything | ||
repr(othermod.ModClass) | ||
|
||
assert isinstance(othermod.ModClass, type) | ||
|
||
def test_modclass_instance(): | ||
mi = othermod.ModClass() | ||
|
||
repr(mi) | ||
repr(mi.__class__) | ||
|
||
assert isinstance(mi, othermod.ModClass) | ||
assert isinstance(mi, object) | ||
|
||
@given(x=USIZE_ST) | ||
def test_modclas_noop(x): | ||
mi = othermod.ModClass() | ||
|
||
assert mi.noop(x) == x | ||
|