| 1 |
# This test code was written by the `hypothesis.extra.ghostwriter` module |
| 2 |
# and is provided under the Creative Commons Zero public domain dedication. |
| 3 |
|
| 4 |
import test_expected_output |
| 5 |
from hypothesis import given, strategies as st |
| 6 |
|
| 7 |
add_operands = st.floats() |
| 8 |
|
| 9 |
|
| 10 |
@given(a=add_operands, b=add_operands, c=add_operands) |
| 11 |
def test_associative_binary_operation_add(a: float, b: float, c) -> None: |
| 12 |
left = test_expected_output.add(a=a, b=test_expected_output.add(a=b, b=c)) |
| 13 |
right = test_expected_output.add(a=test_expected_output.add(a=a, b=b), b=c) |
| 14 |
assert left == right, (left, right) |
| 15 |
|
| 16 |
|
| 17 |
@given(a=add_operands, b=add_operands) |
| 18 |
def test_commutative_binary_operation_add(a: float, b: float) -> None: |
| 19 |
left = test_expected_output.add(a=a, b=b) |
| 20 |
right = test_expected_output.add(a=b, b=a) |
| 21 |
assert left == right, (left, right) |
| 22 |
|
| 23 |
|
| 24 |
@given(a=add_operands) |
| 25 |
def test_identity_binary_operation_add(a: float) -> None: |
| 26 |
identity = 0.0 |
| 27 |
assert a == test_expected_output.add(a=a, b=identity) |
| 28 |
assert a == test_expected_output.add(a=identity, b=a) |