jmessa Tue Feb 19 10:54:02 2008 UTC Modified files: /php-src/ext/standard/tests/array natcasesort_error.phpt natcasesort_variation5.phpt natcasesort_object1.phpt natcasesort_variation1.phpt natcasesort_variation11.phpt natcasesort_variation9.phpt natcasesort_object2.phpt natcasesort_variation10.phpt natcasesort_variation7.phpt natcasesort_variation6.phpt natcasesort_variation8.phpt natcasesort_basic.phpt natcasesort_variation3.phpt natcasesort_variation2.phpt natcasesort_variation4.phpt Log: - New tests for natcasesort() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_error.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_error.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_error.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,53 @@ +--TEST-- +Test natcasesort() function : error conditions - Pass incorrect number of args +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass incorrect number of arguments to natcasesort() to test behaviour + */ + +echo "*** Testing natcasesort() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing natcasesort() function with Zero arguments --\n"; +var_dump( natcasesort() ); + +// Test natcasesort with one more than the expected number of arguments +echo "\n-- Testing natcasesort() function with more than expected no. of arguments --\n"; +$array_arg = array(1, 2); +$extra_arg = 10; +var_dump( natcasesort($array_arg, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : error conditions *** + +-- Testing natcasesort() function with Zero arguments -- + +Warning: natcasesort() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing natcasesort() function with more than expected no. of arguments -- + +Warning: natcasesort() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing natcasesort() : error conditions *** + +-- Testing natcasesort() function with Zero arguments -- + +Warning: natcasesort() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing natcasesort() function with more than expected no. of arguments -- + +Warning: natcasesort() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation5.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation5.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,77 @@ +--TEST-- +Test natcasesort() function : usage variations - different hex values +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass an array of different hex values to test how natcasesort() re-orders it + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +$unsorted_hex_array = array(0x1AB, 0xFFF, 0xF, 0xFF, 0x2AA, 0xBB, 0x1ab, 0xff, -0xFF, 0, -0x2aa); +var_dump( natcasesort($unsorted_hex_array) ); +var_dump($unsorted_hex_array); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(11) { + [8]=> + int(-255) + [10]=> + int(-682) + [9]=> + int(0) + [2]=> + int(15) + [5]=> + int(187) + [3]=> + int(255) + [7]=> + int(255) + [0]=> + int(427) + [6]=> + int(427) + [4]=> + int(682) + [1]=> + int(4095) +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(11) { + [8]=> + int(-255) + [10]=> + int(-682) + [9]=> + int(0) + [2]=> + int(15) + [5]=> + int(187) + [3]=> + int(255) + [7]=> + int(255) + [0]=> + int(427) + [6]=> + int(427) + [4]=> + int(682) + [1]=> + int(4095) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_object1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_object1.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_object1.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_object1.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,147 @@ +--TEST-- +Test natcasesort() function : object functionality - array of objects +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass natcasesort() an array of objects to test how it re-orders them + */ + +echo "*** Testing natcasesort() : object functionality ***\n"; + +// class declaration for string objects +class for_string_natcasesort +{ + public $class_value; + // initializing object member value + function __construct($value){ + $this->class_value = $value; + } + + // return string value + function __tostring() { + return (string)$this->class_value; + } + +} + + + +// array of string objects +$unsorted_str_obj = array ( + new for_string_natcasesort("axx"), new for_string_natcasesort("t"), + new for_string_natcasesort("w"), new for_string_natcasesort("py"), + new for_string_natcasesort("apple"), new for_string_natcasesort("Orange"), + new for_string_natcasesort("Lemon"), new for_string_natcasesort("aPPle") +); + + +echo "\n-- Testing natcasesort() by supplying various object arrays --\n"; + +// testing natcasesort() function by supplying string object array +var_dump(natcasesort($unsorted_str_obj) ); +var_dump($unsorted_str_obj); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : object functionality *** + +-- Testing natcasesort() by supplying various object arrays -- +bool(true) +array(8) { + [4]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(5) "apple" + } + [7]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(5) "aPPle" + } + [0]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(3) "axx" + } + [6]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(5) "Lemon" + } + [5]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(6) "Orange" + } + [3]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(2) "py" + } + [1]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(1) "t" + } + [2]=> + object(for_string_natcasesort)#%d (1) { + ["class_value"]=> + string(1) "w" + } +} +Done +--UEXPECTF-- +*** Testing natcasesort() : object functionality *** + +-- Testing natcasesort() by supplying various object arrays -- +bool(true) +array(8) { + [4]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(5) "apple" + } + [7]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(5) "aPPle" + } + [0]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(3) "axx" + } + [6]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(5) "Lemon" + } + [5]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(6) "Orange" + } + [3]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(2) "py" + } + [1]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(1) "t" + } + [2]=> + object(for_string_natcasesort)#%d (1) { + [u"class_value"]=> + unicode(1) "w" + } +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation1.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation1.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,344 @@ +--TEST-- +Test natcasesort() function : usage variations - Pass different data types as $array_arg arg +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass different data types as $array_arg argument to natcasesort() to test behaviour + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $array_arg argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of natcasesort() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( natcasesort($input) ); + $iterator++; +}; + +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Iteration 1 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 25 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Iteration 1 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL + +-- Iteration 25 -- + +Warning: natcasesort(): The argument should be an array in %s on line %d +NULL +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation11.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation11.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation11.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation11.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,350 @@ +--TEST-- +Test natcasesort() function : usage variations - Different array keys +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass arrays where the keys are different data types to test behaviour of natcasesort() + */ + +echo "*** Testing natcasesort() : usage variations ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// arrays with keys as different data types to be passed as $array_arg +$inputs = array( + + // int data +/*1*/ 'int' => array( + 0 => 'zero', + 1 => 'one', + 12345 => 'positive', + -2345 => 'negative', + ), + + // float data +/*2*/ 'float' => array( + 10.5 => 'positive', + -10.5 => 'negative', + .5 => 'half', + ), + +/*3*/ 'extreme floats' => array( + 12.3456789000e6 => 'large', + 12.3456789000E-10 => 'small', + ), + + // null data +/*4*/ 'null uppercase' => array( + NULL => 'null 1', + ), + +/*5*/ 'null lowercase' => array( + null => 'null 2', + ), + + // boolean data +/*6*/ 'bool lowercase' => array( + true => 'lowert', + false => 'lowerf', + ), + +/*7*/ 'bool uppercase' => array( + TRUE => 'uppert', + FALSE => 'upperf', + ), + + // empty data +/*8*/ 'empty double quotes' => array( + "" => 'emptyd', + ), + +/*9*/ 'empty single quotes' => array( + '' => 'emptys', + ), + + // string data +/*10*/ 'string' => array( + "stringd" => 'stringd', + 'strings' => 'strings', + $heredoc => 'stringh', + ), + + // undefined data +/*11*/ 'undefined' => array( + @$undefined_var => 'undefined', + ), + + // unset data +/*12*/ 'unset' => array( + @$unset_var => 'unset', + ), + + // duplicate values +/*13*/ 'duplicate' => array( + 'foo' => 'bar', + 'baz' => 'bar', + 'hello' => 'world' + ), + +); + +// loop through each element of $inputs to check the behavior of natcasesort() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( natcasesort($input) ); + var_dump($input); + $iterator++; +}; + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : usage variations *** + +-- Iteration 1 -- +bool(true) +array(4) { + [-2345]=> + string(8) "negative" + [1]=> + string(3) "one" + [12345]=> + string(8) "positive" + [0]=> + string(4) "zero" +} + +-- Iteration 2 -- +bool(true) +array(3) { + [0]=> + string(4) "half" + [-10]=> + string(8) "negative" + [10]=> + string(8) "positive" +} + +-- Iteration 3 -- +bool(true) +array(2) { + [12345678]=> + string(5) "large" + [0]=> + string(5) "small" +} + +-- Iteration 4 -- +bool(true) +array(1) { + [""]=> + string(6) "null 1" +} + +-- Iteration 5 -- +bool(true) +array(1) { + [""]=> + string(6) "null 2" +} + +-- Iteration 6 -- +bool(true) +array(2) { + [0]=> + string(6) "lowerf" + [1]=> + string(6) "lowert" +} + +-- Iteration 7 -- +bool(true) +array(2) { + [0]=> + string(6) "upperf" + [1]=> + string(6) "uppert" +} + +-- Iteration 8 -- +bool(true) +array(1) { + [""]=> + string(6) "emptyd" +} + +-- Iteration 9 -- +bool(true) +array(1) { + [""]=> + string(6) "emptys" +} + +-- Iteration 10 -- +bool(true) +array(3) { + ["stringd"]=> + string(7) "stringd" + ["hello world"]=> + string(7) "stringh" + ["strings"]=> + string(7) "strings" +} + +-- Iteration 11 -- +bool(true) +array(1) { + [""]=> + string(9) "undefined" +} + +-- Iteration 12 -- +bool(true) +array(1) { + [""]=> + string(5) "unset" +} + +-- Iteration 13 -- +bool(true) +array(3) { + ["foo"]=> + string(3) "bar" + ["baz"]=> + string(3) "bar" + ["hello"]=> + string(5) "world" +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variations *** + +-- Iteration 1 -- +bool(true) +array(4) { + [-2345]=> + unicode(8) "negative" + [1]=> + unicode(3) "one" + [12345]=> + unicode(8) "positive" + [0]=> + unicode(4) "zero" +} + +-- Iteration 2 -- +bool(true) +array(3) { + [0]=> + unicode(4) "half" + [-10]=> + unicode(8) "negative" + [10]=> + unicode(8) "positive" +} + +-- Iteration 3 -- +bool(true) +array(2) { + [12345678]=> + unicode(5) "large" + [0]=> + unicode(5) "small" +} + +-- Iteration 4 -- +bool(true) +array(1) { + [u""]=> + unicode(6) "null 1" +} + +-- Iteration 5 -- +bool(true) +array(1) { + [u""]=> + unicode(6) "null 2" +} + +-- Iteration 6 -- +bool(true) +array(2) { + [0]=> + unicode(6) "lowerf" + [1]=> + unicode(6) "lowert" +} + +-- Iteration 7 -- +bool(true) +array(2) { + [0]=> + unicode(6) "upperf" + [1]=> + unicode(6) "uppert" +} + +-- Iteration 8 -- +bool(true) +array(1) { + [u""]=> + unicode(6) "emptyd" +} + +-- Iteration 9 -- +bool(true) +array(1) { + [u""]=> + unicode(6) "emptys" +} + +-- Iteration 10 -- +bool(true) +array(3) { + [u"stringd"]=> + unicode(7) "stringd" + [u"hello world"]=> + unicode(7) "stringh" + [u"strings"]=> + unicode(7) "strings" +} + +-- Iteration 11 -- +bool(true) +array(1) { + [u""]=> + unicode(9) "undefined" +} + +-- Iteration 12 -- +bool(true) +array(1) { + [u""]=> + unicode(5) "unset" +} + +-- Iteration 13 -- +bool(true) +array(3) { + [u"foo"]=> + unicode(3) "bar" + [u"baz"]=> + unicode(3) "bar" + [u"hello"]=> + unicode(5) "world" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation9.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation9.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation9.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation9.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,186 @@ +--TEST-- +Test natcasesort() function : usage variations - mixed array +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass an array containing sub-arrays, ints, floats, strings, boolean, null + * and escape characters to test how natcasesort() re-orders it + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +$mixed_values = array ( + array(), + array( array(33, -5, 6), + array(11), + array(22, -55), + array() + ), + -4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "", + NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false +); +// suppress errors as is generating a lot of "array to string" notices +var_dump( @natcasesort($mixed_values) ); + +var_dump($mixed_values); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(22) { + [13]=> + NULL + [19]=> + string(0) "" + [21]=> + bool(false) + [12]=> + string(0) "" + [10]=> + string(3) "-.9" + [7]=> + int(-2) + [8]=> + float(-2) + [9]=> + float(-2.98989) + [2]=> + int(-4) + [16]=> + float(0) + [17]=> + int(0) + [20]=> + bool(true) + [3]=> + string(1) "4" + [4]=> + float(4) + [6]=> + string(1) "5" + [14]=> + string(2) "ab" + [15]=> + string(4) "abcd" + [18]=> + string(14) "%s" + [0]=> + array(0) { + } + [1]=> + array(4) { + [0]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } + [1]=> + array(1) { + [0]=> + int(11) + } + [2]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [3]=> + array(0) { + } + } + [5]=> + string(1) "b" + [11]=> + string(4) "True" +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(22) { + [13]=> + NULL + [19]=> + unicode(0) "" + [21]=> + bool(false) + [12]=> + unicode(0) "" + [10]=> + unicode(3) "-.9" + [7]=> + int(-2) + [8]=> + float(-2) + [9]=> + float(-2.98989) + [2]=> + int(-4) + [16]=> + float(0) + [17]=> + int(0) + [20]=> + bool(true) + [3]=> + unicode(1) "4" + [4]=> + float(4) + [6]=> + unicode(1) "5" + [14]=> + unicode(2) "ab" + [15]=> + unicode(4) "abcd" + [18]=> + unicode(14) "%s" + [0]=> + array(0) { + } + [1]=> + array(4) { + [0]=> + array(3) { + [0]=> + int(33) + [1]=> + int(-5) + [2]=> + int(6) + } + [1]=> + array(1) { + [0]=> + int(11) + } + [2]=> + array(2) { + [0]=> + int(22) + [1]=> + int(-55) + } + [3]=> + array(0) { + } + } + [5]=> + unicode(1) "b" + [11]=> + unicode(4) "True" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_object2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_object2.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_object2.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_object2.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,143 @@ +--TEST-- +Test natcasesort() function : object functionality - mixed visibility within objects +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass natcasesort() an array of objects which have properties of different + * visibilities to test how it re-orders the array. + */ + +echo "*** Testing natcasesort() : object functionality ***\n"; + +// class declaration for string objects +class for_string_natcasesort +{ + public $public_class_value; + private $private_class_value; + protected $protected_class_value; + // initializing object member value + function __construct($value1, $value2,$value3){ + $this->public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } + + // return string value + function __tostring() { + return (string)$this->public_class_value; + } + +} + +// array of string objects +$unsorted_str_obj = array ( +new for_string_natcasesort("axx","AXX","ass"), +new for_string_natcasesort("t","eee","abb"), +new for_string_natcasesort("w","W", "c"), +new for_string_natcasesort("py","PY", "pt"), +); + + +echo "\n-- Testing natcasesort() by supplying object arrays --\n"; + +// testing natcasesort() function by supplying string object array +$temp_array = $unsorted_str_obj; +var_dump(natcasesort($temp_array) ); +var_dump($temp_array); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : object functionality *** + +-- Testing natcasesort() by supplying object arrays -- +bool(true) +array(4) { + [0]=> + object(for_string_natcasesort)#%d (3) { + ["public_class_value"]=> + string(3) "axx" + ["private_class_value":"for_string_natcasesort":private]=> + string(3) "AXX" + ["protected_class_value":protected]=> + string(3) "ass" + } + [3]=> + object(for_string_natcasesort)#%d (3) { + ["public_class_value"]=> + string(2) "py" + ["private_class_value":"for_string_natcasesort":private]=> + string(2) "PY" + ["protected_class_value":protected]=> + string(2) "pt" + } + [1]=> + object(for_string_natcasesort)#%d (3) { + ["public_class_value"]=> + string(1) "t" + ["private_class_value":"for_string_natcasesort":private]=> + string(3) "eee" + ["protected_class_value":protected]=> + string(3) "abb" + } + [2]=> + object(for_string_natcasesort)#%d (3) { + ["public_class_value"]=> + string(1) "w" + ["private_class_value":"for_string_natcasesort":private]=> + string(1) "W" + ["protected_class_value":protected]=> + string(1) "c" + } +} +Done +--UEXPECTF-- +*** Testing natcasesort() : object functionality *** + +-- Testing natcasesort() by supplying object arrays -- +bool(true) +array(4) { + [0]=> + object(for_string_natcasesort)#%d (3) { + [u"public_class_value"]=> + unicode(3) "axx" + [u"private_class_value":u"for_string_natcasesort":private]=> + unicode(3) "AXX" + [u"protected_class_value":protected]=> + unicode(3) "ass" + } + [3]=> + object(for_string_natcasesort)#%d (3) { + [u"public_class_value"]=> + unicode(2) "py" + [u"private_class_value":u"for_string_natcasesort":private]=> + unicode(2) "PY" + [u"protected_class_value":protected]=> + unicode(2) "pt" + } + [1]=> + object(for_string_natcasesort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "t" + [u"private_class_value":u"for_string_natcasesort":private]=> + unicode(3) "eee" + [u"protected_class_value":protected]=> + unicode(3) "abb" + } + [2]=> + object(for_string_natcasesort)#%d (3) { + [u"public_class_value"]=> + unicode(1) "w" + [u"private_class_value":u"for_string_natcasesort":private]=> + unicode(1) "W" + [u"protected_class_value":protected]=> + unicode(1) "c" + } +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation10.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation10.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation10.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation10.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,75 @@ +--TEST-- +Test natcasesort() function : usage variations - position of internal array pointer +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Check position of internal array pointer after calling natcasesort() + */ + +echo "*** Testing natcasesort() : usage variations ***\n"; + +$array_arg = array ('img13', 'img20', 'img2', 'img1'); + +echo "\n-- Initial Position of Internal Pointer: --\n"; +echo key($array_arg) . " => " . current ($array_arg) . "\n"; + +echo "\n-- Call natcasesort() --\n"; +var_dump(natcasesort($array_arg)); +var_dump($array_arg); + +echo "\n-- Position of Internal Pointer in Passed Array: --\n"; +echo key($array_arg) . " => " . current ($array_arg) . "\n"; + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : usage variations *** + +-- Initial Position of Internal Pointer: -- +0 => img13 + +-- Call natcasesort() -- +bool(true) +array(4) { + [3]=> + string(4) "img1" + [2]=> + string(4) "img2" + [0]=> + string(5) "img13" + [1]=> + string(5) "img20" +} + +-- Position of Internal Pointer in Passed Array: -- +3 => img1 +Done + +--UEXPECTF-- +*** Testing natcasesort() : usage variations *** + +-- Initial Position of Internal Pointer: -- +0 => img13 + +-- Call natcasesort() -- +bool(true) +array(4) { + [3]=> + unicode(4) "img1" + [2]=> + unicode(4) "img2" + [0]=> + unicode(5) "img13" + [1]=> + unicode(5) "img20" +} + +-- Position of Internal Pointer in Passed Array: -- +3 => img1 +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation7.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation7.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,168 @@ +--TEST-- +Test natcasesort() function : usage variations - recursive arrays +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass natcasesort() an infinitely recursive array to test how it is re-ordered + */ + +echo "*** Testing natcasesort() : usage variations ***\n"; + +$array = array (1, 3.00, 'zero', '2'); +$array[] = &$array; +var_dump($array); + +var_dump(@natcasesort($array)); +var_dump($array); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : usage variations *** +array(5) { + [0]=> + int(1) + [1]=> + float(3) + [2]=> + string(4) "zero" + [3]=> + string(1) "2" + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + float(3) + [2]=> + string(4) "zero" + [3]=> + string(1) "2" + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + float(3) + [2]=> + string(4) "zero" + [3]=> + string(1) "2" + [4]=> + *RECURSION* + } + } +} +bool(true) +array(5) { + [0]=> + int(1) + [3]=> + string(1) "2" + [1]=> + float(3) + [4]=> + &array(5) { + [0]=> + int(1) + [3]=> + string(1) "2" + [1]=> + float(3) + [4]=> + &array(5) { + [0]=> + int(1) + [3]=> + string(1) "2" + [1]=> + float(3) + [4]=> + *RECURSION* + [2]=> + string(4) "zero" + } + [2]=> + string(4) "zero" + } + [2]=> + string(4) "zero" +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variations *** +array(5) { + [0]=> + int(1) + [1]=> + float(3) + [2]=> + unicode(4) "zero" + [3]=> + unicode(1) "2" + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + float(3) + [2]=> + unicode(4) "zero" + [3]=> + unicode(1) "2" + [4]=> + &array(5) { + [0]=> + int(1) + [1]=> + float(3) + [2]=> + unicode(4) "zero" + [3]=> + unicode(1) "2" + [4]=> + *RECURSION* + } + } +} +bool(true) +array(5) { + [0]=> + int(1) + [3]=> + unicode(1) "2" + [1]=> + float(3) + [4]=> + &array(5) { + [0]=> + int(1) + [3]=> + unicode(1) "2" + [1]=> + float(3) + [4]=> + &array(5) { + [0]=> + int(1) + [3]=> + unicode(1) "2" + [1]=> + float(3) + [4]=> + *RECURSION* + [2]=> + unicode(4) "zero" + } + [2]=> + unicode(4) "zero" + } + [2]=> + unicode(4) "zero" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation6.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation6.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,81 @@ +--TEST-- +Test natcasesort() function : usage variations - referenced variables +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass an array of referenced varaibles to test how natcasesort() re-orders it + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +$value1 = 100; +$value2 = 33; +$value3 = 555; + +echo "\n-- Initial test --\n"; +$array = array( &$value1 , &$value2, &$value3); +var_dump( natcasesort($array) ); +var_dump($array); + +echo "\n-- Change \$value1 --\n"; +$value1 = -29; +var_dump( natcasesort($array) ); +var_dump($array); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Initial test -- +bool(true) +array(3) { + [1]=> + &int(33) + [0]=> + &int(100) + [2]=> + &int(555) +} + +-- Change $value1 -- +bool(true) +array(3) { + [0]=> + &int(-29) + [1]=> + &int(33) + [2]=> + &int(555) +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Initial test -- +bool(true) +array(3) { + [1]=> + &int(33) + [0]=> + &int(100) + [2]=> + &int(555) +} + +-- Change $value1 -- +bool(true) +array(3) { + [0]=> + &int(-29) + [1]=> + &int(33) + [2]=> + &int(555) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation8.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation8.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation8.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation8.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,70 @@ +--TEST-- +Test natcasesort() function : usage variations - octal values +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass an array of octal values to test how natcasesort() re-orders it + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +$unsorted_oct_array = array(01235, 0321, 0345, 066, 0772, 077, -066, -0345, 0); + +var_dump( natcasesort($unsorted_oct_array) ); +var_dump($unsorted_oct_array); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(9) { + [6]=> + int(-54) + [7]=> + int(-229) + [8]=> + int(0) + [3]=> + int(54) + [5]=> + int(63) + [1]=> + int(209) + [2]=> + int(229) + [4]=> + int(506) + [0]=> + int(669) +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(9) { + [6]=> + int(-54) + [7]=> + int(-229) + [8]=> + int(0) + [3]=> + int(54) + [5]=> + int(63) + [1]=> + int(209) + [2]=> + int(229) + [4]=> + int(506) + [0]=> + int(669) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_basic.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_basic.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_basic.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,89 @@ +--TEST-- +Test natcasesort() function : basic functionality +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Test basic functionality of natcasesort() + */ + +echo "*** Testing natcasesort() : basic functionality ***\n"; + +$array = array ('A01', 'a1', 'b10', 'a01', 'b01'); +echo "\n-- Before sorting: --\n"; +var_dump($array); + +echo "\n-- After Sorting: --\n"; +var_dump(natcasesort($array)); +var_dump($array); + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : basic functionality *** + +-- Before sorting: -- +array(5) { + [0]=> + string(3) "A01" + [1]=> + string(2) "a1" + [2]=> + string(3) "b10" + [3]=> + string(3) "a01" + [4]=> + string(3) "b01" +} + +-- After Sorting: -- +bool(true) +array(5) { + [3]=> + string(3) "a01" + [0]=> + string(3) "A01" + [1]=> + string(2) "a1" + [4]=> + string(3) "b01" + [2]=> + string(3) "b10" +} +Done +--UEXPECTF-- +*** Testing natcasesort() : basic functionality *** + +-- Before sorting: -- +array(5) { + [0]=> + unicode(3) "A01" + [1]=> + unicode(2) "a1" + [2]=> + unicode(3) "b10" + [3]=> + unicode(3) "a01" + [4]=> + unicode(3) "b01" +} + +-- After Sorting: -- +bool(true) +array(5) { + [3]=> + unicode(3) "a01" + [0]=> + unicode(3) "A01" + [1]=> + unicode(2) "a1" + [4]=> + unicode(3) "b01" + [2]=> + unicode(3) "b10" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation3.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation3.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,222 @@ +--TEST-- +Test natcasesort() function : usage variations - different numeric types +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass arrays of numeric data to test how natcasesort re-orders the array + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +$inputs = array ( + + // negative/positive integers array + array(11, -11, 21, -21, 31, -31, 0, 41, -41), + + // float value array + array(10.5, -10.5, 10.5e2, 10.6E-2, .5, .01, -.1), + + // mixed value array + array(.0001, .0021, -.01, -1, 0, .09, 2, -.9, 10.6E-2, -10.6E-2, 33), + + // array values contains minimum and maximum ranges + array(2147483647, 2147483648, -2147483647, -2147483648, -0, 0, -2147483649) +); + +$iterator = 1; +foreach ($inputs as $array_arg) { + echo "\n-- Iteration $iterator --\n"; + var_dump(natcasesort($array_arg)); + var_dump($array_arg); +} + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Iteration 1 -- +bool(true) +array(9) { + [1]=> + int(-11) + [3]=> + int(-21) + [5]=> + int(-31) + [8]=> + int(-41) + [6]=> + int(0) + [0]=> + int(11) + [2]=> + int(21) + [4]=> + int(31) + [7]=> + int(41) +} + +-- Iteration 1 -- +bool(true) +array(7) { + [6]=> + float(-0.1) + [1]=> + float(-10.5) + [5]=> + float(0.01) + [4]=> + float(0.5) + [3]=> + float(0.106) + [0]=> + float(10.5) + [2]=> + float(1050) +} + +-- Iteration 1 -- +bool(true) +array(11) { + [2]=> + float(-0.01) + [7]=> + float(-0.9) + [9]=> + float(-0.106) + [3]=> + int(-1) + [4]=> + int(0) + [0]=> + float(0.0001) + [1]=> + float(0.0021) + [5]=> + float(0.09) + [8]=> + float(0.106) + [6]=> + int(2) + [10]=> + int(33) +} + +-- Iteration 1 -- +bool(true) +array(7) { + [2]=> + int(-2147483647) + [3]=> + float(-2147483648) + [6]=> + float(-2147483649) + [5]=> + int(0) + [4]=> + int(0) + [0]=> + int(2147483647) + [1]=> + float(2147483648) +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Iteration 1 -- +bool(true) +array(9) { + [1]=> + int(-11) + [3]=> + int(-21) + [5]=> + int(-31) + [8]=> + int(-41) + [6]=> + int(0) + [0]=> + int(11) + [2]=> + int(21) + [4]=> + int(31) + [7]=> + int(41) +} + +-- Iteration 1 -- +bool(true) +array(7) { + [6]=> + float(-0.1) + [1]=> + float(-10.5) + [5]=> + float(0.01) + [4]=> + float(0.5) + [3]=> + float(0.106) + [0]=> + float(10.5) + [2]=> + float(1050) +} + +-- Iteration 1 -- +bool(true) +array(11) { + [2]=> + float(-0.01) + [7]=> + float(-0.9) + [9]=> + float(-0.106) + [3]=> + int(-1) + [4]=> + int(0) + [0]=> + float(0.0001) + [1]=> + float(0.0021) + [5]=> + float(0.09) + [8]=> + float(0.106) + [6]=> + int(2) + [10]=> + int(33) +} + +-- Iteration 1 -- +bool(true) +array(7) { + [2]=> + int(-2147483647) + [3]=> + float(-2147483648) + [6]=> + float(-2147483649) + [5]=> + int(0) + [4]=> + int(0) + [0]=> + int(2147483647) + [1]=> + float(2147483648) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation2.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation2.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,334 @@ +--TEST-- +Test natcasesort() function : usage variations - Pass arrays of different data types +--FILE-- +<?php + +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass arrays of different data types to natcasesort() to test how they are sorted + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// arrays of different data types to be passed to $array_arg argument +$inputs = array( + + // int data +/*1*/ 'int' => array( + 0, + 1, + 12345, + -2345, + ), + + // float data +/*2*/ 'float' => array( + 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + ), + + // null data +/*3*/ 'null' => array( + NULL, + null, + ), + + // boolean data +/*4*/ 'bool' => array( + true, + false, + TRUE, + FALSE, + ), + + // empty data +/*5*/ 'empty string' => array( + "", + '', + ), + +/*6*/ 'empty array' => array( + ), + + // string data +/*7*/ 'string' => array( + "string", + 'string', + $heredoc, + ), + + // object data +/*8*/ 'object' => array( + new classA(), + ), + + // undefined data +/*9*/ 'undefined' => array( + @$undefined_var, + ), + + // unset data +/*10*/ 'unset' => array( + @$unset_var, + ), + + // resource variable +/*11*/ 'resource' => array( + $fp + ), +); +// loop through each element of $inputs to check the behavior of natcasesort() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( natcasesort($input) ); + var_dump($input); + $iterator++; +}; + +fclose($fp); + +echo "Done"; +?> + +--EXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Iteration 1 -- +bool(true) +array(4) { + [3]=> + int(-2345) + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(12345) +} + +-- Iteration 2 -- +bool(true) +array(5) { + [1]=> + float(-10.5) + [4]=> + float(0.5) + [3]=> + float(1.23456789E-9) + [0]=> + float(10.5) + [2]=> + float(123456789000) +} + +-- Iteration 3 -- +bool(true) +array(2) { + [1]=> + NULL + [0]=> + NULL +} + +-- Iteration 4 -- +bool(true) +array(4) { + [3]=> + bool(false) + [1]=> + bool(false) + [0]=> + bool(true) + [2]=> + bool(true) +} + +-- Iteration 5 -- +bool(true) +array(2) { + [1]=> + string(0) "" + [0]=> + string(0) "" +} + +-- Iteration 6 -- +bool(true) +array(0) { +} + +-- Iteration 7 -- +bool(true) +array(3) { + [2]=> + string(11) "hello world" + [1]=> + string(6) "string" + [0]=> + string(6) "string" +} + +-- Iteration 8 -- +bool(true) +array(1) { + [0]=> + object(classA)#%d (0) { + } +} + +-- Iteration 9 -- +bool(true) +array(1) { + [0]=> + NULL +} + +-- Iteration 10 -- +bool(true) +array(1) { + [0]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + [0]=> + resource(%d) of type (stream) +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** + +-- Iteration 1 -- +bool(true) +array(4) { + [3]=> + int(-2345) + [0]=> + int(0) + [1]=> + int(1) + [2]=> + int(12345) +} + +-- Iteration 2 -- +bool(true) +array(5) { + [1]=> + float(-10.5) + [4]=> + float(0.5) + [3]=> + float(1.23456789E-9) + [0]=> + float(10.5) + [2]=> + float(123456789000) +} + +-- Iteration 3 -- +bool(true) +array(2) { + [1]=> + NULL + [0]=> + NULL +} + +-- Iteration 4 -- +bool(true) +array(4) { + [3]=> + bool(false) + [1]=> + bool(false) + [0]=> + bool(true) + [2]=> + bool(true) +} + +-- Iteration 5 -- +bool(true) +array(2) { + [1]=> + unicode(0) "" + [0]=> + unicode(0) "" +} + +-- Iteration 6 -- +bool(true) +array(0) { +} + +-- Iteration 7 -- +bool(true) +array(3) { + [2]=> + unicode(11) "hello world" + [1]=> + unicode(6) "string" + [0]=> + unicode(6) "string" +} + +-- Iteration 8 -- +bool(true) +array(1) { + [0]=> + object(classA)#%d (0) { + } +} + +-- Iteration 9 -- +bool(true) +array(1) { + [0]=> + NULL +} + +-- Iteration 10 -- +bool(true) +array(1) { + [0]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + [0]=> + resource(%d) of type (stream) +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/natcasesort_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/natcasesort_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/array/natcasesort_variation4.phpt:1.2 --- /dev/null Tue Feb 19 10:54:02 2008 +++ php-src/ext/standard/tests/array/natcasesort_variation4.phpt Tue Feb 19 10:54:02 2008 @@ -0,0 +1,142 @@ +--TEST-- +Test natcasesort() function : usage variations - different string types +--FILE-- +<?php +/* Prototype : bool natcasesort(array &$array_arg) + * Description: Sort an array using case-insensitive natural sort + * Source code: ext/standard/array.c + */ + +/* + * Pass arrays of string data to see how natcasesort() re-orders the array + */ + +echo "*** Testing natcasesort() : usage variation ***\n"; + +$inputs = array ( + // group of escape sequences + array(null, NULL, "\a", "\cx", "\e", "\f", "\n", "\t", "\xhh", "\ddd", "\v"), + + // array contains combination of capital/small letters + array("lemoN", "Orange", "banana", "apple", "Test", "TTTT", "ttt", "ww", "x", "X", "oraNGe", "BANANA") +); + +foreach ($inputs as $array_arg) { + var_dump( natcasesort($array_arg) ); + var_dump($array_arg); +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(11) { + [6]=> + string(1) " +" + [7]=> + string(1) " " + [10]=> + string(1) "" + [0]=> + NULL + [5]=> + string(1) "" + [1]=> + NULL + [2]=> + string(2) "\a" + [3]=> + string(3) "\cx" + [9]=> + string(4) "\ddd" + [4]=> + string(2) "\e" + [8]=> + string(4) "\xhh" +} +bool(true) +array(12) { + [3]=> + string(5) "apple" + [11]=> + string(6) "BANANA" + [2]=> + string(6) "banana" + [0]=> + string(5) "lemoN" + [10]=> + string(6) "oraNGe" + [1]=> + string(6) "Orange" + [4]=> + string(4) "Test" + [6]=> + string(3) "ttt" + [5]=> + string(4) "TTTT" + [7]=> + string(2) "ww" + [8]=> + string(1) "x" + [9]=> + string(1) "X" +} +Done +--UEXPECTF-- +*** Testing natcasesort() : usage variation *** +bool(true) +array(11) { + [0]=> + NULL + [1]=> + NULL + [7]=> + unicode(1) " " + [6]=> + unicode(1) " +" + [10]=> + unicode(1) "" + [5]=> + unicode(1) "" + [2]=> + unicode(2) "\a" + [3]=> + unicode(3) "\cx" + [9]=> + unicode(4) "\ddd" + [4]=> + unicode(2) "\e" + [8]=> + unicode(4) "\xhh" +} +bool(true) +array(12) { + [3]=> + unicode(5) "apple" + [11]=> + unicode(6) "BANANA" + [2]=> + unicode(6) "banana" + [0]=> + unicode(5) "lemoN" + [10]=> + unicode(6) "oraNGe" + [1]=> + unicode(6) "Orange" + [4]=> + unicode(4) "Test" + [6]=> + unicode(3) "ttt" + [5]=> + unicode(4) "TTTT" + [7]=> + unicode(2) "ww" + [8]=> + unicode(1) "x" + [9]=> + unicode(1) "X" +} +Done \ No newline at end of file
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php