wharmby Sun Jan 18 22:51:00 2009 UTC Modified files: /php-src/ext/standard/tests/strings nl_langinfo_error1.phpt ord_variation1.phpt ord_basic.phpt nl_langinfo_basic.phpt number_format_error.phpt number_format_basic.phpt nl_langinfo_variation1.phpt ord_error.phpt Log: New nl_langinfo(), number_format() and ord() tests. Tested on Windows. Linux and Linux 64 bit
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/nl_langinfo_error1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/nl_langinfo_error1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/nl_langinfo_error1.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/nl_langinfo_error1.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,40 @@ +--TEST-- +Test nl_langinfo() function : error conditions +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == 'WIN'){ + die('skip Not for Windows'); +} +?> +--FILE-- +<?php + +/* Prototype : string nl_langinfo ( int $item ) + * Description: Query language and locale information + * Source code: ext/standard/string.c +*/ + +echo "*** Testing nl_langinfo() : error conditions ***\n"; + +echo "\n-- Testing nl_langinfo() function with no arguments --\n"; +var_dump( nl_langinfo() ); + +echo "\n-- Testing nl_langinfo() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( nl_langinfo(ABDAY_2, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing nl_langinfo() : error conditions *** + +-- Testing nl_langinfo() function with no arguments -- + +Warning: nl_langinfo() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing nl_langinfo() function with more than expected no. of arguments -- + +Warning: nl_langinfo() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/ord_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/ord_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/ord_variation1.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/ord_variation1.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,137 @@ +--TEST-- +Test ord() function : usage variations - test values for $string argument +--FILE-- +<?php + +/* Prototype : int ord ( string $string ) + * Description: Return ASCII value of character + * Source code: ext/standard/string.c +*/ + +echo "*** Testing ord() function: with unexpected inputs for 'string' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$inputs = array ( + + // integer values +/*1*/ 0, + 1, + 255, + 256, + 2147483647, + -2147483648, + + // float values +/*7*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*10*/ array(), + array(0), + array(1, 2), + + // boolean values +/*13*/ true, + false, + TRUE, + FALSE, + + // null values +/*17*/ NULL, + null, + + // objects +/*19*/ new sample(), + + // resource +/*20*/ $file_handle, + + // undefined variable +/*21*/ @$undefined_var, + + // unset variable +/*22*/ @$unset_var +); + +// loop through with each element of the $string array to test ord() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( ord($input) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing ord() function: with unexpected inputs for 'string' argument *** +-- Iteration 1 -- +int(48) +-- Iteration 2 -- +int(49) +-- Iteration 3 -- +int(50) +-- Iteration 4 -- +int(50) +-- Iteration 5 -- +int(50) +-- Iteration 6 -- +int(45) +-- Iteration 7 -- +int(49) +-- Iteration 8 -- +int(45) +-- Iteration 9 -- +int(49) +-- Iteration 10 -- + +Warning: ord() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: ord() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: ord() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- +int(49) +-- Iteration 14 -- +int(0) +-- Iteration 15 -- +int(49) +-- Iteration 16 -- +int(0) +-- Iteration 17 -- +int(0) +-- Iteration 18 -- +int(0) +-- Iteration 19 -- +int(115) +-- Iteration 20 -- + +Warning: ord() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 21 -- +int(0) +-- Iteration 22 -- +int(0) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/ord_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/ord_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/ord_basic.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/ord_basic.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,47 @@ +--TEST-- +Test ord() function : basic functionality +--FILE-- +<?php + +/* Prototype : int ord ( string $string ) + * Description: Return ASCII value of character + * Source code: ext/standard/string.c +*/ + +echo "*** Testing ord() : basic functionality ***\n"; + +var_dump(ord("a")); +var_dump(ord("z")); +var_dump(ord("0")); +var_dump(ord("9")); +var_dump(ord("!")); +var_dump(ord("*")); +var_dump(ord("@")); +var_dump(ord("\n")); +var_dump(ord("\x0A")); +var_dump(ord("\xFF")); +var_dump(ord("Hello")); + +// Make sure all valid ascii chars round trip +for ($i = 0; $i < 255; $i++) { + if (ord(chr($i)) != $i) { + exit("TEST FAILED: $i does not round trip\n"); + } +} + +?> +===DONE=== +--EXPECT-- +*** Testing ord() : basic functionality *** +int(97) +int(122) +int(48) +int(57) +int(33) +int(42) +int(64) +int(10) +int(10) +int(255) +int(72) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/nl_langinfo_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/nl_langinfo_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/nl_langinfo_basic.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/nl_langinfo_basic.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,51 @@ +--TEST-- +Test nl_langinfo() function : basic functionality +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == 'WIN'){ + die('skip Not for Windows'); +} +?> +--FILE-- +<?php + +/* Prototype : string nl_langinfo ( int $item ) + * Description: Query language and locale information + * Source code: ext/standard/string.c +*/ + +echo "*** Testing nl_langinfo() : basic functionality ***\n"; + +$original = setlocale(LC_ALL, 'C'); + +var_dump(nl_langinfo(ABDAY_2)); +var_dump(nl_langinfo(DAY_4)); +var_dump(nl_langinfo(ABMON_7)); +var_dump(nl_langinfo(MON_4)); +var_dump(nl_langinfo(RADIXCHAR)); + +setlocale(LC_ALL, $original); +?> +===DONE=== +--EXPECTF-- +*** Testing nl_langinfo() : basic functionality *** + +Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +string(3) "Mon" + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +string(9) "Wednesday" + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +string(3) "Jul" + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +string(5) "April" + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +string(1) "." + +Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/number_format_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/number_format_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/number_format_error.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/number_format_error.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,31 @@ +--TEST-- +Test number_format() - wrong params test number_format() +--FILE-- +<?php +/* Prototype : string number_format ( float $number [, int $decimals ] ) + * string number_format ( float $number , int $decimals , string $dec_point , string $thousands_sep ) + * Description: Format a number with grouped thousands + * Source code: ext/standard/string.c + */ + +echo "*** Testing number_format() : error conditions ***\n"; + +echo "\n-- Testing number_format() function with less than expected no. of arguments --\n"; +number_format(); + +echo "\n-- Testing number_format() function with more than 4 arguments --\n"; +number_format(23,2,true,false,36); + +?> +===DONE=== +--EXPECTF-- +*** Testing number_format() : error conditions *** + +-- Testing number_format() function with less than expected no. of arguments -- + +Warning: number_format() expects at least 1 parameter, 0 given in %s on line %d + +-- Testing number_format() function with more than 4 arguments -- + +Warning: number_format() expects at most 4 parameters, 5 given in %s on line %d +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/number_format_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/number_format_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/number_format_basic.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/number_format_basic.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,109 @@ +--TEST-- +Test number_format() - basic function test number_format() +--FILE-- +<?php +/* Prototype : string number_format ( float $number [, int $decimals ] ) + * string number_format ( float $number , int $decimals , string $dec_point , string $thousands_sep ) + * Description: Format a number with grouped thousands + * Source code: ext/standard/string.c + */ + +echo "*** Testing number_format() : basic functionality ***\n"; + +$values = array(1234.5678, + -1234.5678, + 1234.6578e4, + -1234.56789e4, + 0x1234CDEF, + 02777777777, + "123456789", + "123.456789", + "12.3456789e1", + null, + true, + false); + +echo "\n number_format tests.....default\n"; +for ($i = 0; $i < count($values); $i++) { + $res = number_format($values[$i]); + var_dump($res); +} + +echo "\n number_format tests.....with two dp\n"; +for ($i = 0; $i < count($values); $i++) { + $res = number_format($values[$i], 2); + var_dump($res); +} + +echo "\n number_format tests.....English format\n"; +for ($i = 0; $i < count($values); $i++) { + $res = number_format($values[$i], 2, '.', ' '); + var_dump($res); +} + +echo "\n number_format tests.....French format\n"; +for ($i = 0; $i < count($values); $i++) { + $res = number_format($values[$i], 2, ',' , ' '); + var_dump($res); +} +?> +===DONE=== +--EXPECTF-- +*** Testing number_format() : basic functionality *** + + number_format tests.....default +unicode(5) "1,235" +unicode(6) "-1,235" +unicode(10) "12,346,578" +unicode(11) "-12,345,679" +unicode(11) "305,450,479" +unicode(11) "402,653,183" +unicode(11) "123,456,789" +unicode(3) "123" +unicode(3) "123" +unicode(1) "0" +unicode(1) "1" +unicode(1) "0" + + number_format tests.....with two dp +unicode(8) "1,234.57" +unicode(9) "-1,234.57" +unicode(13) "12,346,578.00" +unicode(14) "-12,345,678.90" +unicode(14) "305,450,479.00" +unicode(14) "402,653,183.00" +unicode(14) "123,456,789.00" +unicode(6) "123.46" +unicode(6) "123.46" +unicode(4) "0.00" +unicode(4) "1.00" +unicode(4) "0.00" + + number_format tests.....English format +unicode(8) "1 234.57" +unicode(9) "-1 234.57" +unicode(13) "12 346 578.00" +unicode(14) "-12 345 678.90" +unicode(14) "305 450 479.00" +unicode(14) "402 653 183.00" +unicode(14) "123 456 789.00" +unicode(6) "123.46" +unicode(6) "123.46" +unicode(4) "0.00" +unicode(4) "1.00" +unicode(4) "0.00" + + number_format tests.....French format +unicode(8) "1 234,57" +unicode(9) "-1 234,57" +unicode(13) "12 346 578,00" +unicode(14) "-12 345 678,90" +unicode(14) "305 450 479,00" +unicode(14) "402 653 183,00" +unicode(14) "123 456 789,00" +unicode(6) "123,46" +unicode(6) "123,46" +unicode(4) "0,00" +unicode(4) "1,00" +unicode(4) "0,00" +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/nl_langinfo_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/nl_langinfo_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/nl_langinfo_variation1.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/nl_langinfo_variation1.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,216 @@ +--TEST-- +Test nl_langinfo() function : unexpected inputs for '$tem' argument +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == 'WIN'){ + die('skip Not for Windows'); +} +?> +--FILE-- +<?php + +/* Prototype : string nl_langinfo ( int $item ) + * Description: Query language and locale information + * Source code: ext/standard/string.c +*/ + +echo "*** Testing nl_langinfo() : with unexpected inputs for 'item' argument ***\n"; + +$original = setlocale(LC_ALL, 'C'); + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$items = array ( + + // integer values +/*1*/ 0, + 10, + 2147483647, + -2147483648, + + // float values +/*5*/ 10.5, + 20.3, + -20.5, + 10.1234567e5, + + // array values +/*9*/ array(), + array(0), + array(1, 2), + + // boolean values +/*12*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*16*/ NULL, + null, + + // objects +/*18*/ new sample(), + + // resource +/*19*/ $file_handle, + + // undefined variable +/*20*/ @$undefined_var, + + // unset variable +/*21*/ @$unset_var +); + +//defining '$input' argument +$input = "Test string"; + +// loop through with each element of the $items array to test nl_langinfo() function +$count = 1; +foreach($items as $item) { + echo "-- Iteration $count --\n"; + var_dump( nl_langinfo($item) ); + $count ++; +} + +fclose($file_handle); //closing the file handle +setlocale(LC_ALL, $original); + +?> +===DONE=== +--EXPECTF-- +*** Testing nl_langinfo() : with unexpected inputs for 'item' argument *** + +Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +-- Iteration 1 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) +-- Iteration 2 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '10' is not valid in %s on line %d +bool(false) +-- Iteration 3 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '2147483647' is not valid in %s on line %d +bool(false) +-- Iteration 4 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '-2147483648' is not valid in %s on line %d +bool(false) +-- Iteration 5 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '10' is not valid in %s on line %d +bool(false) +-- Iteration 6 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '20' is not valid in %s on line %d +bool(false) +-- Iteration 7 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '-20' is not valid in %s on line %d +bool(false) +-- Iteration 8 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '1012345' is not valid in %s on line %d +bool(false) +-- Iteration 9 -- + +Warning: nl_langinfo() expects parameter 1 to be long, array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: nl_langinfo() expects parameter 1 to be long, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: nl_langinfo() expects parameter 1 to be long, array given in %s on line %d +NULL +-- Iteration 12 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '1' is not valid in %s on line %d +bool(false) +-- Iteration 13 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) +-- Iteration 14 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '1' is not valid in %s on line %d +bool(false) +-- Iteration 15 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) +-- Iteration 16 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) +-- Iteration 17 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: nl_langinfo() expects parameter 1 to be long, object given in %s on line %d +NULL +-- Iteration 19 -- + +Warning: nl_langinfo() expects parameter 1 to be long, resource given in %s on line %d +NULL +-- Iteration 20 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) +-- Iteration 21 -- + +Deprecated: nl_langinfo(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d + +Warning: nl_langinfo(): Item '0' is not valid in %s on line %d +bool(false) + +Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/ord_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/ord_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/ord_error.phpt:1.2 --- /dev/null Sun Jan 18 22:51:00 2009 +++ php-src/ext/standard/tests/strings/ord_error.phpt Sun Jan 18 22:51:00 2009 @@ -0,0 +1,34 @@ +--TEST-- +Test ord() function : error conditions +--FILE-- +<?php + +/* Prototype : int ord ( string $string ) + * Description: Return ASCII value of character + * Source code: ext/standard/string.c +*/ + +echo "*** Testing ord() : error conditions ***\n"; + +echo "\n-- Testing ord() function with no arguments --\n"; +var_dump( ord() ); + +echo "\n-- Testing ord() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( ord(72, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing ord() : error conditions *** + +-- Testing ord() function with no arguments -- + +Warning: ord() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ord() function with more than expected no. of arguments -- + +Warning: ord() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php