Annotation of embedaddon/php/ext/standard/tests/array/rsort_variation5.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test rsort() function : usage variations - String values
! 3: --SKIPIF--
! 4: <?php
! 5: if (substr(PHP_OS, 0, 3) == 'WIN') {
! 6: die("skip Output tested contains chars that are not shown the same on windows concole (ESC and co)");
! 7: }
! 8: --FILE--
! 9: <?php
! 10: /* Prototype : bool rsort(array &$array_arg [, int $sort_flags])
! 11: * Description: Sort an array in reverse order
! 12: * Source code: ext/standard/array.c
! 13: */
! 14:
! 15: /*
! 16: * Pass arrays containing different string data to rsort() to test behaviour
! 17: */
! 18:
! 19: echo "*** Testing rsort() : variation ***\n";
! 20:
! 21: $various_arrays = array (
! 22: // group of escape sequences
! 23: array(null, NULL, "\a", "\cx", "\e", "\f", "\n", "\t", "\xhh", "\ddd", "\v"),
! 24:
! 25: // array contains combination of capital/small letters
! 26: array("lemoN", "Orange", "banana", "apple", "Test", "TTTT", "ttt", "ww", "x", "X", "oraNGe", "BANANA")
! 27: );
! 28:
! 29: $flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING);
! 30:
! 31: $count = 1;
! 32: // loop through to test rsort() with different arrays
! 33: foreach ($various_arrays as $array) {
! 34: echo "\n-- Iteration $count --\n";
! 35:
! 36: echo "- With Default sort flag -\n";
! 37: $temp_array = $array;
! 38: var_dump(rsort($temp_array) );
! 39: var_dump($temp_array);
! 40:
! 41: // loop through $flags array and setting all possible flag values
! 42: foreach($flags as $key => $flag){
! 43: echo "- Sort flag = $key -\n";
! 44:
! 45: $temp_array = $array;
! 46: var_dump(rsort($temp_array, $flag) );
! 47: var_dump($temp_array);
! 48: }
! 49: $count++;
! 50: }
! 51:
! 52: echo "Done";
! 53: ?>
! 54:
! 55: --EXPECTF--
! 56: *** Testing rsort() : variation ***
! 57:
! 58: -- Iteration 1 --
! 59: - With Default sort flag -
! 60: bool(true)
! 61: array(11) {
! 62: [0]=>
! 63: string(4) "\xhh"
! 64: [1]=>
! 65: string(2) "\e"
! 66: [2]=>
! 67: string(4) "\ddd"
! 68: [3]=>
! 69: string(3) "\cx"
! 70: [4]=>
! 71: string(2) "\a"
! 72: [5]=>
! 73: string(1) ""
! 74: [6]=>
! 75: string(1) ""
! 76: [7]=>
! 77: string(1) "
! 78: "
! 79: [8]=>
! 80: string(1) " "
! 81: [9]=>
! 82: NULL
! 83: [10]=>
! 84: NULL
! 85: }
! 86: - Sort flag = SORT_REGULAR -
! 87: bool(true)
! 88: array(11) {
! 89: [0]=>
! 90: string(4) "\xhh"
! 91: [1]=>
! 92: string(2) "\e"
! 93: [2]=>
! 94: string(4) "\ddd"
! 95: [3]=>
! 96: string(3) "\cx"
! 97: [4]=>
! 98: string(2) "\a"
! 99: [5]=>
! 100: string(1) ""
! 101: [6]=>
! 102: string(1) ""
! 103: [7]=>
! 104: string(1) "
! 105: "
! 106: [8]=>
! 107: string(1) " "
! 108: [9]=>
! 109: NULL
! 110: [10]=>
! 111: NULL
! 112: }
! 113: - Sort flag = SORT_STRING -
! 114: bool(true)
! 115: array(11) {
! 116: [0]=>
! 117: string(4) "\xhh"
! 118: [1]=>
! 119: string(2) "\e"
! 120: [2]=>
! 121: string(4) "\ddd"
! 122: [3]=>
! 123: string(3) "\cx"
! 124: [4]=>
! 125: string(2) "\a"
! 126: [5]=>
! 127: string(1) ""
! 128: [6]=>
! 129: string(1) ""
! 130: [7]=>
! 131: string(1) "
! 132: "
! 133: [8]=>
! 134: string(1) " "
! 135: [9]=>
! 136: NULL
! 137: [10]=>
! 138: NULL
! 139: }
! 140:
! 141: -- Iteration 2 --
! 142: - With Default sort flag -
! 143: bool(true)
! 144: array(12) {
! 145: [0]=>
! 146: string(1) "x"
! 147: [1]=>
! 148: string(2) "ww"
! 149: [2]=>
! 150: string(3) "ttt"
! 151: [3]=>
! 152: string(6) "oraNGe"
! 153: [4]=>
! 154: string(5) "lemoN"
! 155: [5]=>
! 156: string(6) "banana"
! 157: [6]=>
! 158: string(5) "apple"
! 159: [7]=>
! 160: string(1) "X"
! 161: [8]=>
! 162: string(4) "Test"
! 163: [9]=>
! 164: string(4) "TTTT"
! 165: [10]=>
! 166: string(6) "Orange"
! 167: [11]=>
! 168: string(6) "BANANA"
! 169: }
! 170: - Sort flag = SORT_REGULAR -
! 171: bool(true)
! 172: array(12) {
! 173: [0]=>
! 174: string(1) "x"
! 175: [1]=>
! 176: string(2) "ww"
! 177: [2]=>
! 178: string(3) "ttt"
! 179: [3]=>
! 180: string(6) "oraNGe"
! 181: [4]=>
! 182: string(5) "lemoN"
! 183: [5]=>
! 184: string(6) "banana"
! 185: [6]=>
! 186: string(5) "apple"
! 187: [7]=>
! 188: string(1) "X"
! 189: [8]=>
! 190: string(4) "Test"
! 191: [9]=>
! 192: string(4) "TTTT"
! 193: [10]=>
! 194: string(6) "Orange"
! 195: [11]=>
! 196: string(6) "BANANA"
! 197: }
! 198: - Sort flag = SORT_STRING -
! 199: bool(true)
! 200: array(12) {
! 201: [0]=>
! 202: string(1) "x"
! 203: [1]=>
! 204: string(2) "ww"
! 205: [2]=>
! 206: string(3) "ttt"
! 207: [3]=>
! 208: string(6) "oraNGe"
! 209: [4]=>
! 210: string(5) "lemoN"
! 211: [5]=>
! 212: string(6) "banana"
! 213: [6]=>
! 214: string(5) "apple"
! 215: [7]=>
! 216: string(1) "X"
! 217: [8]=>
! 218: string(4) "Test"
! 219: [9]=>
! 220: string(4) "TTTT"
! 221: [10]=>
! 222: string(6) "Orange"
! 223: [11]=>
! 224: string(6) "BANANA"
! 225: }
! 226: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>