Annotation of embedaddon/php/ext/ctype/tests/ctype_xdigit_variation4.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test ctype_xdigit() function : usage variations - heaxadecimal and octal values
                      3: --SKIPIF--
                      4: <?php require_once('skipif.inc'); ?>
                      5: --FILE--
                      6: <?php
                      7: /* Prototype  : bool ctype_xdigit(mixed $c)
                      8:  * Description: Checks for character(s) representing a hexadecimal digit 
                      9:  * Source code: ext/ctype/ctype.c
                     10:  */
                     11: 
                     12: /*
                     13:  * Pass different hexadecimal and octal values that:
                     14:  * 1. contain hexadecimal digits
                     15:  * 2. correspond to character codes recognised as hexadecimal digits (see variation2)
                     16:  *    referred to as 'correct' integers below
                     17:  */
                     18: 
                     19: echo "*** Testing ctype_xdigit() : usage variations ***\n";
                     20: 
                     21: $orig = setlocale(LC_CTYPE, "C"); 
                     22: 
                     23: // contain hexadecimal digits but do not correspond to 'correct' ints
                     24: $octal_values1 = array(012, 013, 014, 015);
                     25: 
                     26: // correspond to 'correct' integers
                     27: $octal_values2 = array(061, 062, 063, 064);
                     28: 
                     29: // contain hexadecimal digits but do not correspond to 'correct' ints
                     30: $hex_values1 = array(0x1A, 0x1B, 0x1C, 0x1D);
                     31: 
                     32: //correspond to 'correct' integers
                     33: $hex_values2 = array(0x61, 0x62, 0x63, 0x64);
                     34: 
                     35: echo "\n-- Octal values --\n";
                     36: echo "'Incorrect' Integers: \n";
                     37: foreach($octal_values1 as $c) {
                     38:        var_dump(ctype_xdigit($c));
                     39: }
                     40: echo "'Correct' Integers: \n";
                     41: foreach($octal_values2 as $c) {
                     42:        var_dump(ctype_xdigit($c));
                     43: }
                     44: 
                     45: echo "\n-- Hexadecimal values --\n";
                     46: echo "'Incorrect' Integers: \n";
                     47: foreach($hex_values1 as $c) {
                     48:        var_dump(ctype_xdigit($c));
                     49: }
                     50: echo "'Correct' Integers: \n";
                     51: foreach($hex_values2 as $c) {
                     52:        var_dump(ctype_xdigit($c));
                     53: }
                     54: setlocale(LC_CTYPE, $orig); 
                     55: ?>
                     56: ===DONE===
                     57: --EXPECTF--
                     58: *** Testing ctype_xdigit() : usage variations ***
                     59: 
                     60: -- Octal values --
                     61: 'Incorrect' Integers: 
                     62: bool(false)
                     63: bool(false)
                     64: bool(false)
                     65: bool(false)
                     66: 'Correct' Integers: 
                     67: bool(true)
                     68: bool(true)
                     69: bool(true)
                     70: bool(true)
                     71: 
                     72: -- Hexadecimal values --
                     73: 'Incorrect' Integers: 
                     74: bool(false)
                     75: bool(false)
                     76: bool(false)
                     77: bool(false)
                     78: 'Correct' Integers: 
                     79: bool(true)
                     80: bool(true)
                     81: bool(true)
                     82: bool(true)
                     83: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>