Fix: trailing zeros added to the rounded value with split units
When units were split into larger and smaller values, the larger value is rounded and should not show trailing zeros. Trailing zeros should only be used for the smaller unit. Ref !140790
This commit is contained in:
@@ -60,15 +60,25 @@ class UnitsTesting(unittest.TestCase):
|
||||
# LENGTH
|
||||
# Note: precision handling is a bit complicated when using multi-units...
|
||||
('IMPERIAL', 'LENGTH', 3, False, False, 0.3048, "1'"),
|
||||
('IMPERIAL', 'LENGTH', -3, False, False, 0.3048, "1.000'"),
|
||||
('IMPERIAL', 'LENGTH', 3, False, True, 0.3048, "1ft"),
|
||||
('IMPERIAL', 'LENGTH', -3, False, True, 0.3048, "1.000ft"),
|
||||
('IMPERIAL', 'LENGTH', -6, False, True, 0.3048, "1.000000ft"),
|
||||
('IMPERIAL', 'LENGTH', -7, False, True, 0.3048, "1.000000ft"),
|
||||
('IMPERIAL', 'LENGTH', 4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.5\""),
|
||||
('IMPERIAL', 'LENGTH', -4, True, False, 0.3048 * 2 + 0.0254 * 5.5, "2' 5.50\""),
|
||||
('IMPERIAL', 'LENGTH', 3, False, False, 1609.344 * 1e6, "1000000 mi"),
|
||||
('IMPERIAL', 'LENGTH', 6, False, False, 1609.344 * 1e6, "1000000 mi"),
|
||||
('METRIC', 'LENGTH', 3, True, False, 1000 * 2 + 0.001 * 15, "2 km 2 cm"),
|
||||
('METRIC', 'LENGTH', 3, True, False, 0.000005, "5 µm"),
|
||||
('METRIC', 'LENGTH', -3, True, False, 0.000005, "5.00 µm"),
|
||||
('METRIC', 'LENGTH', 5, True, False, 1234.56789, "1 km 234.6 m"),
|
||||
('METRIC', 'LENGTH', 6, True, False, 1234.56789, "1 km 234.57 m"),
|
||||
('METRIC', 'LENGTH', 9, False, False, 1234.56789, "1.234568 km"),
|
||||
('METRIC', 'LENGTH', 9, True, False, 1000.000123456789, "1 km 0.123 mm"),
|
||||
('METRIC', 'LENGTH', 7, True, False, 0, "0 m"),
|
||||
('METRIC', 'LENGTH', -5, True, False, 0, "0.00000 m"),
|
||||
('METRIC', 'LENGTH', -7, True, False, 0, "0.000000 m"),
|
||||
)
|
||||
|
||||
def test_units_inputs(self):
|
||||
|
||||
Reference in New Issue
Block a user