File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
ctype /
tests /
ctype_xdigit_variation4.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:47:53 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
Test ctype_xdigit() function : usage variations - heaxadecimal and octal values
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
/* Prototype : bool ctype_xdigit(mixed $c)
* Description: Checks for character(s) representing a hexadecimal digit
* Source code: ext/ctype/ctype.c
*/
/*
* 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);
?>
===DONE===
--EXPECTF--
*** 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)
===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>