File: natcasesort_variation3.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (129 lines) | stat: -rw-r--r-- 1,885 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
--TEST--
Test natcasesort() function : usage variations - different numeric types
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
/*
 * 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";
?>
--EXPECT--
*** 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)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [0]=>
  int(2147483647)
  [1]=>
  float(2147483648)
}
Done