Ejemplo n.º 1
0
def testUSD():
    w = AgentWallet()

    w.depositUSD(13.25)
    assert w.USD() == 13.25

    w.depositUSD(1.00)
    assert w.USD() == 14.25

    w.withdrawUSD(2.10)
    assert w.USD() == 12.15

    w.depositUSD(0.0)
    w.withdrawUSD(0.0)
    assert w.USD() == 12.15

    assert w.totalUSDin() == (13.25 + 1.0)

    with pytest.raises(AssertionError):
        w.depositUSD(-5.0)

    with pytest.raises(AssertionError):
        w.withdrawUSD(-5.0)

    with pytest.raises(ValueError):
        w.withdrawUSD(1000.0)
Ejemplo n.º 2
0
def testFloatingPointRoundoff_USD():
    w = AgentWallet(USD=2.4)
    w.withdrawUSD(2.4000000000000004)  #should not get ValueError
    assert w.USD() == 0.0
    assert w.OCEAN() == 0.0