mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 23:04:21 +01:00
tests: add unit testts for orderbook, order and subscriptions
This commit is contained in:
committed by
Jacob Plaster
parent
77fb4b1bac
commit
ac0abe54c5
24
bfxapi/tests/test_decimal.py
Normal file
24
bfxapi/tests/test_decimal.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import sys
|
||||
sys.path.append('../components')
|
||||
|
||||
from bfxapi import Decimal
|
||||
|
||||
def test_precision():
|
||||
assert str(Decimal(0.00000123456789)) == "0.00000123456789"
|
||||
assert str(Decimal("0.00000123456789")) == "0.00000123456789"
|
||||
|
||||
def test_float_operations():
|
||||
assert str(Decimal(0.0002) * 0.02) == "0.000004"
|
||||
assert str(0.02 * Decimal(0.0002)) == "0.000004"
|
||||
|
||||
assert str(Decimal(0.0002) / 0.02) == "0.01"
|
||||
assert str(0.02 / Decimal(0.0002)) == "0.01"
|
||||
|
||||
assert str(0.02 + Decimal(0.0002)) == "0.0202"
|
||||
assert str(Decimal(0.0002) + 0.02) == "0.0202"
|
||||
|
||||
assert str(0.02 - Decimal(0.0002)) == "-0.0198"
|
||||
assert str(Decimal(0.0002) - 0.02) == "-0.0198"
|
||||
|
||||
assert str(0.01 // Decimal(0.0004)) == "0"
|
||||
assert str(Decimal(0.0004) // 0.01) == "0"
|
||||
Reference in New Issue
Block a user