fix tolerance
This commit is contained in:
parent
798d068ec0
commit
9288c9dd56
2 changed files with 21 additions and 0 deletions
19
test.py
Normal file
19
test.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import random
|
||||
from splitbill import solve, perform_transfers
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("tolerance", [0, 1, 2, 10, 100])
|
||||
def test_random(tolerance):
|
||||
balances = {str(k): random.randint(-200, 200) for k in range(7)}
|
||||
balances["7"] = -sum(balances.values())
|
||||
balances = {k: v for k, v in balances.items() if v != 0}
|
||||
transactions = solve(balances, tolerance)
|
||||
assert abs(sum(perform_transfers(balances, transactions).values())) <= tolerance
|
||||
|
||||
|
||||
def test_bug1():
|
||||
tolerance = 100
|
||||
balances = {'0': -39, '1': 139, '2': -54, '3': 99, '4': 13, '5': 175, '6': -173, '7': -160}
|
||||
transactions = solve(balances, tolerance=tolerance)
|
||||
assert abs(sum(perform_transfers(balances, transactions).values())) <= tolerance
|
||||
Loading…
Add table
Add a link
Reference in a new issue