def test_to_usd(): """ Tests the to_usd function. """ assert to_usd(1000.2342) == "$1,000.23" assert to_usd(100.23) == "$100.23" assert to_usd(100.2) == "$100.20"
def test_usd(): result = to_usd(10) result2 = to_usd(57.3333) result3 = to_usd(.011111111) assert result == "$10.00" assert result2 == "$57.33" assert result3 == "$0.01"
def test_to_usd(): # dollar sign display assert to_usd(2.34) == "$2.34" # display two decimal places assert to_usd(2.3) == "$2.30" # display a thousands separator assert to_usd(23456789.3333) == "$23,456,789.33"
def test_to_usd(): #Should apply correct formatting assert to_usd(7.25) == "$7.25" #Should display two decimal places assert to_usd(8.5) == "$8.50" #Should round to two places assert to_usd(3.444444) == "$3.44" #Should display comma separators assert to_usd(1234567890.5555555) == "$1,234,567,890.56"
def test_to_usd(): # it should apply USD formatting: assert to_usd(4.50) == "$4.50" # it should display two decimal places: assert to_usd(4.5) == "$4.50" # it should round to two places: assert to_usd(4.55555) == "$4.56" # it should display thousands separators: assert to_usd(1234567890.5555555) == "$1,234,567,890.56"
def test_to_usd(): #adapted from https://github.com/s2t2/shopping-cart-screencast/blob/testing/shopping_cart_test.py # it should apply USD formatting assert to_usd(4.50) == "$4.50" # it should display two decimal places assert to_usd(4.5) == "$4.50" # it should round to two places assert to_usd(4.55555) == "$4.56" # it should display thousands separators assert to_usd(1234567890.5555555) == "$1,234,567,890.56"
def test_to_usd_isNegative(): result = to_usd(-1.23) assert result == '$-1.23'
def test_to_usd_isLongFloat(): result = to_usd(1.2345) assert result == '$1.23'
def test_to_usd_isFloat(): result = to_usd(1.23) assert result == '$1.23'
def test_to_usd_isDoubleDigit(): result = to_usd(20) assert result == '$20.00'
def test_to_usd_isSingleDigit(): result = to_usd(1) assert result == '$1.00'
def test_to_usd(): assert to_usd(23.50) == "$23.50" assert to_usd(2) == "$2.00" assert to_usd(1230.4) == "$1,230.40"
def test_to_usd(): result = to_usd(73498.82) assert result == " $73,498.82" assert to_usd(9.9) == " $9.90"
def test_to_usd(): assert to_usd(5) == "$5.00" assert to_usd(5.777) == "$5.78" assert to_usd(12345) == "$12,345.00"
def test_to_usd_isZero(): result = to_usd(0) assert result == '$0.00'
def test_to_usd_thousandsSeperator(): result = to_usd(1000) assert len(result.split(",")) > 1
def test_usd(): result1 = to_usd(3.5111111) result2 = to_usd(10) assert result1 == "$3.51" assert result2 == "$10.00"
def test_to_usd(): assert to_usd(8.88) == "$8.88"
def test_to_usd(): price = 4050.13 assert to_usd(price) == "$4,050.13"