]> granicus.if.org Git - php/commitdiff
Restrict ctype tests to POSIX portable characters (0..127) and add numeric character...
authorPreston L. Bannister <pbannister@php.net>
Thu, 16 May 2002 21:55:26 +0000 (21:55 +0000)
committerPreston L. Bannister <pbannister@php.net>
Thu, 16 May 2002 21:55:26 +0000 (21:55 +0000)
ext/ctype/tests/002.phpt

index 8ccc1c7f75d76bda5967a213170c5f32a695af13..f002b3b93344751f221768d001d115f88383c37b 100644 (file)
@@ -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