summaryrefslogtreecommitdiff
path: root/lulua/test_report.py
blob: 816aa8539df00f8e37550e6c284fad32a47d96c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from decimal import Decimal

from .report import approx

def test_approx ():
    assert approx (0) == (Decimal ('0'), '')
    assert approx (0.01) == (Decimal ('0'), '')
    assert approx (0.05) == (Decimal ('0.1'), '')
    assert approx (1) == (Decimal ('1'), '')
    assert approx (100) == (Decimal ('100'), '')
    assert approx (999.9) == (Decimal ('999.9'), '')
    assert approx (999.91) == (Decimal ('999.9'), '')
    assert approx (999.99) == (Decimal ('1'), 'thousand')

    assert approx (10**3) == (Decimal ('1'), 'thousand')
    assert approx (10**6) == (Decimal ('1'), 'million')
    assert approx (10**9) == (Decimal ('1'), 'billion')
    assert approx (10**12) == (Decimal ('1000'), 'billion')