mirror of
https://github.com/php/php-src.git
synced 2024-12-03 23:05:57 +08:00
Restrict ctype tests to POSIX portable characters (0..127) and add numeric character tests.
This commit is contained in:
parent
1fdff888ce
commit
e3ae02255b
@ -6,17 +6,22 @@ ctype on strings
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
setlocale(LC_ALL,"C");
|
||||
|
||||
function ctype_test_002($function) {
|
||||
$n=0; $m=0;
|
||||
for($a=0;$a<256;$a++) {
|
||||
$c = chr($a);
|
||||
if($function("$c$c$c")) $n++;
|
||||
if($function("1-$c$c$c-x")) $m++;
|
||||
}
|
||||
echo "$function $n $m\n";
|
||||
}
|
||||
setlocale(LC_ALL,"C");
|
||||
print "LOCALE is '" . setlocale(LC_ALL,0) . "'\n";
|
||||
|
||||
function ctype_test_002($function) {
|
||||
$n1 = $n2 = $n3 = 0;
|
||||
// test portable POSIX characters 0..127
|
||||
for ($a=0;$a<128;$a++) {
|
||||
$c = chr($a);
|
||||
if($function($a)) $n1++;
|
||||
if($function("$c$c$c")) $n2++;
|
||||
if($function("1-$c$c$c-x")) $n3++;
|
||||
}
|
||||
print "$function $n1 $n2 $n3\n";
|
||||
}
|
||||
|
||||
ctype_test_002("ctype_lower");
|
||||
ctype_test_002("ctype_upper");
|
||||
ctype_test_002("ctype_alpha");
|
||||
@ -28,16 +33,18 @@ ctype_test_002("ctype_print");
|
||||
ctype_test_002("ctype_punct");
|
||||
ctype_test_002("ctype_space");
|
||||
ctype_test_002("ctype_xdigit");
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
ctype_lower 26 0
|
||||
ctype_upper 26 0
|
||||
ctype_alpha 52 0
|
||||
ctype_digit 10 0
|
||||
ctype_alnum 62 0
|
||||
ctype_cntrl 33 0
|
||||
ctype_graph 94 94
|
||||
ctype_print 95 95
|
||||
ctype_punct 32 0
|
||||
ctype_space 6 0
|
||||
ctype_xdigit 22 0
|
||||
LOCALE is 'C'
|
||||
ctype_lower 26 26 0
|
||||
ctype_upper 26 26 0
|
||||
ctype_alpha 52 52 0
|
||||
ctype_digit 10 10 0
|
||||
ctype_alnum 62 62 0
|
||||
ctype_cntrl 33 33 0
|
||||
ctype_graph 94 94 94
|
||||
ctype_print 95 95 95
|
||||
ctype_punct 32 32 0
|
||||
ctype_space 6 6 0
|
||||
ctype_xdigit 22 22 0
|
||||
|
Loading…
Reference in New Issue
Block a user