summaryrefslogtreecommitdiff
path: root/ext/ctype/tests/ctype_xdigit_variation4.phpt
blob: def93e2250a7b85923db77402b7f059536d77df7 (plain)
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
--TEST--
Test ctype_xdigit() function : usage variations - heaxadecimal and octal values
--EXTENSIONS--
ctype
--FILE--
<?php
/*
 * Pass different hexadecimal and octal values that:
 * 1. contain hexadecimal digits
 * 2. correspond to character codes recognised as hexadecimal digits (see variation2)
 *    referred to as 'correct' integers below
 */

echo "*** Testing ctype_xdigit() : usage variations ***\n";

$orig = setlocale(LC_CTYPE, "C");

// contain hexadecimal digits but do not correspond to 'correct' ints
$octal_values1 = array(012, 013, 014, 015);

// correspond to 'correct' integers
$octal_values2 = array(061, 062, 063, 064);

// contain hexadecimal digits but do not correspond to 'correct' ints
$hex_values1 = array(0x1A, 0x1B, 0x1C, 0x1D);

//correspond to 'correct' integers
$hex_values2 = array(0x61, 0x62, 0x63, 0x64);

echo "\n-- Octal values --\n";
echo "'Incorrect' Integers: \n";
foreach($octal_values1 as $c) {
    var_dump(ctype_xdigit($c));
}
echo "'Correct' Integers: \n";
foreach($octal_values2 as $c) {
    var_dump(ctype_xdigit($c));
}

echo "\n-- Hexadecimal values --\n";
echo "'Incorrect' Integers: \n";
foreach($hex_values1 as $c) {
    var_dump(ctype_xdigit($c));
}
echo "'Correct' Integers: \n";
foreach($hex_values2 as $c) {
    var_dump(ctype_xdigit($c));
}
setlocale(LC_CTYPE, $orig);
?>
--EXPECT--
*** Testing ctype_xdigit() : usage variations ***

-- Octal values --
'Incorrect' Integers: 
bool(false)
bool(false)
bool(false)
bool(false)
'Correct' Integers: 
bool(true)
bool(true)
bool(true)
bool(true)

-- Hexadecimal values --
'Incorrect' Integers: 
bool(false)
bool(false)
bool(false)
bool(false)
'Correct' Integers: 
bool(true)
bool(true)
bool(true)
bool(true)