diff options
| author | Sky <sky@skychristensen.com> | 2019-10-31 13:05:26 +1100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-31 10:48:35 +0100 |
| commit | 3cf907c20c4f4d94f649fbb93a006af5c61b30b8 (patch) | |
| tree | e12dc362ce4a95d621a7046582de751ec893e209 /tests/template_tests | |
| parent | 459de8dc29a45a40f3c22cb63ebd2b82336f7192 (diff) | |
Fixed #30761 -- Prevented floatformat filter from returning a negative zero.
Diffstat (limited to 'tests/template_tests')
| -rw-r--r-- | tests/template_tests/filter_tests/test_floatformat.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py index 9cb838854c..8ad7322af2 100644 --- a/tests/template_tests/filter_tests/test_floatformat.py +++ b/tests/template_tests/filter_tests/test_floatformat.py @@ -64,6 +64,16 @@ class FunctionTests(SimpleTestCase): self.assertEqual(floatformat(0, 10), '0.0000000000') self.assertEqual(floatformat(0.000000000000000000015, 20), '0.00000000000000000002') + def test_negative_zero_values(self): + tests = [ + (-0.01, -1, '0.0'), + (-0.001, 2, '0.00'), + (-0.499, 0, '0'), + ] + for num, decimal_places, expected in tests: + with self.subTest(num=num, decimal_places=decimal_places): + self.assertEqual(floatformat(num, decimal_places), expected) + def test_infinity(self): pos_inf = float(1e30000) neg_inf = float(-1e30000) |
