mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #30761 -- Prevented floatformat filter from returning a negative zero.
This commit is contained in:
parent
459de8dc29
commit
3cf907c20c
4 changed files with 21 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue