mirror of
https://github.com/django/django.git
synced 2025-09-27 12:39:17 +00:00
Fixed #5748 -- Made floatformat filter round properly on all platforms and handle NaN input correctly on Windows. Also added tests for these cases. Thanks for the report and initial patch to SmileyChris and PJCrosier.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9369 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cadbf66635
commit
b81bc22ad2
2 changed files with 63 additions and 15 deletions
|
@ -13,15 +13,15 @@ u'0.1'
|
|||
u'0.0'
|
||||
>>> floatformat(0.0)
|
||||
u'0'
|
||||
>>> floatformat(7.7,3)
|
||||
>>> floatformat(7.7, 3)
|
||||
u'7.700'
|
||||
>>> floatformat(6.000000,3)
|
||||
>>> floatformat(6.000000, 3)
|
||||
u'6.000'
|
||||
>>> floatformat(6.200000, 3)
|
||||
u'6.200'
|
||||
>>> floatformat(6.200000, -3)
|
||||
u'6.200'
|
||||
>>> floatformat(13.1031,-3)
|
||||
>>> floatformat(13.1031, -3)
|
||||
u'13.103'
|
||||
>>> floatformat(11.1197, -2)
|
||||
u'11.12'
|
||||
|
@ -35,10 +35,23 @@ u'8.280'
|
|||
u''
|
||||
>>> floatformat(13.1031, u'bar')
|
||||
u'13.1031'
|
||||
>>> floatformat(18.125, 2)
|
||||
u'18.13'
|
||||
>>> floatformat(u'foo', u'bar')
|
||||
u''
|
||||
>>> floatformat(u'¿Cómo esta usted?')
|
||||
u''
|
||||
>>> floatformat(None)
|
||||
u''
|
||||
>>> pos_inf = float(1e30000)
|
||||
>>> floatformat(pos_inf) == unicode(pos_inf)
|
||||
True
|
||||
>>> neg_inf = float(-1e30000)
|
||||
>>> floatformat(neg_inf) == unicode(neg_inf)
|
||||
True
|
||||
>>> nan = pos_inf / pos_inf
|
||||
>>> floatformat(nan) == unicode(nan)
|
||||
True
|
||||
|
||||
>>> addslashes(u'"double quotes" and \'single quotes\'')
|
||||
u'\\"double quotes\\" and \\\'single quotes\\\''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue