JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
made format_int() fail for 1.0 -> 10
authorJason Woofenden <jason@jasonwoof.com>
Mon, 29 Mar 2010 19:16:58 +0000 (15:16 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Mon, 29 Mar 2010 19:17:11 +0000 (15:17 -0400)
format_int() and friends strip all not-numeric characters. This leads to
unexpected results when the user enters something with a decimal point.

ie 1.0 -> 10,  12.5 -> 125, etc

unit_tests/format.php

index 261ed65..21a1f74 100644 (file)
@@ -122,10 +122,10 @@ function test_format_misc() {
        $errors += _test_format_misc('decimal', '-1', '-1');
        $errors += _test_format_misc('decimal', '+1', '1');
 
-       $errors += _test_format_misc('int', '-1.0', '10'); # FIXME?
-       $errors += _test_format_misc('int', '+1.0', '10'); # FIXME?
-       $errors += _test_format_misc('int_0', '-1.0', '10'); # FIXME?
-       $errors += _test_format_misc('int_0', '+1.0', '10'); # FIXME?
+       $errors += _test_format_misc('int', '-1.0', '1');
+       $errors += _test_format_misc('int', '+1.0', '1');
+       $errors += _test_format_misc('int_0', '-1.0', '1');
+       $errors += _test_format_misc('int_0', '+1.0', '1');
        $errors += _test_format_misc('positive_decimal', '-1.0', '1.0');
        $errors += _test_format_misc('positive_decimal', '+1.0', '1.0');
        $errors += _test_format_misc('decimal', '-1.0', '-1.0');