test for complex conversions

This commit is contained in:
James Turk 2015-03-24 16:27:42 -04:00
parent 9211b27415
commit bff8814fe2
2 changed files with 18 additions and 1 deletions

View File

@ -24,6 +24,19 @@ def test_basic_conversions():
assert g.as_unit('lb').scalar == a.as_unit('lb').scalar
def test_complex_conversions():
a = V(2, ['m', 'm'])
cm2 = a.as_unit(['cm', 'cm'])
assert cm2.scalar == 20000
assert cm2.unit == Unit(['cm', 'cm'])
g = V(9.8, Unit(['m'], ['s', 's']))
g_ft = g.as_unit(Unit(['ft'], ['s', 's']))
assert g_ft.scalar - 32 < 1
assert g_ft.unit == Unit(['ft'], ['s', 's'])
def test_basic_cmp():
assert V(1, 'kg') < V(2, 'kg')
assert V(1, 'kg') <= V(2, 'kg')

View File

@ -7,7 +7,11 @@ _UNITS = {
'lb': {'base': 'kg', 'scale': 2.20462},
'g': {'base': 'kg', 'scale': 1000.0},
'm': {'base': 'm', 'scale': 1.0},
'm': {'base': 'm', 'scale': 1.0},
'cm': {'base': 'm', 'scale': 100.0},
'ft': {'base': 'm', 'scale': 3.28084},
's': {'base': 's', 'scale': 1.0},
}