xref: /php-src/ext/ctype/tests/002.phpt (revision 08069165)
1--TEST--
2ctype on strings
3--EXTENSIONS--
4ctype
5--FILE--
6<?php
7
8setlocale(LC_ALL,"C");
9print "LOCALE is '" . setlocale(LC_ALL,0) . "'\n";
10
11function ctype_test_002($function) {
12    $n1 = $n2 = $n3 = 0;
13    // test portable POSIX characters 0..127
14    for ($a=0;$a<128;$a++) {
15        $c = chr($a);
16        if($function($c)) $n1++;
17        if($function("$c$c$c")) $n2++;
18        if($function("1-$c$c$c-x")) $n3++;
19    }
20    print "$function $n1 $n2 $n3\n";
21}
22
23ctype_test_002("ctype_lower");
24ctype_test_002("ctype_upper");
25ctype_test_002("ctype_alpha");
26ctype_test_002("ctype_digit");
27ctype_test_002("ctype_alnum");
28ctype_test_002("ctype_cntrl");
29ctype_test_002("ctype_graph");
30ctype_test_002("ctype_print");
31ctype_test_002("ctype_punct");
32ctype_test_002("ctype_space");
33ctype_test_002("ctype_xdigit");
34
35?>
36--EXPECTF--
37LOCALE is '%s'
38ctype_lower 26 26 0
39ctype_upper 26 26 0
40ctype_alpha 52 52 0
41ctype_digit 10 10 0
42ctype_alnum 62 62 0
43ctype_cntrl 33 33 0
44ctype_graph 94 94 94
45ctype_print 95 95 95
46ctype_punct 32 32 0
47ctype_space 6 6 0
48ctype_xdigit 22 22 0
49