File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
strings /
strncasecmp_basic.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:04 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 strncasecmp() function : basic functionality
--FILE--
<?php
/* Prototype : int strncasecmp ( string $str1, string $str2, int $len );
* Description: Binary safe case-insensitive string comparison of the first n characters
* Source code: Zend/zend_builtin_functions.c
*/
echo "*** Testing strncasecmp() function: basic functionality ***\n";
echo "-- Testing strncasecmp() with single quoted string --\n";
var_dump( strncasecmp('Hello', 'Hello', 5) ); //expected: int(0)
var_dump( strncasecmp('Hello', 'Hi', 5) ); //expected: value < 0
var_dump( strncasecmp('Hi', 'Hello', 5) ); //expected: value > 0
echo "-- Testing strncasecmp() with double quoted string --\n";
var_dump( strncasecmp("Hello", "Hello", 5) ); //expected: int(0)
var_dump( strncasecmp("Hello", "Hi", 5) ); //expected: value < 0
var_dump( strncasecmp("Hi", "Hello", 5) ); //expected: value > 0
echo "-- Testing strncasecmp() with here-doc string --\n";
$str = <<<HEREDOC
Hello
HEREDOC;
var_dump( strncasecmp($str, "Hello", 5) ); //expected: int(0)
var_dump( strncasecmp($str, "Hi", 5) ); //expected: value < 0
var_dump( strncasecmp("Hi", $str, 5) ); //expected: value > 0
echo "*** Done ***";
?>
--EXPECTREGEX--
\*\*\* Testing strncasecmp\(\) function: basic functionality \*\*\*
-- Testing strncasecmp\(\) with single quoted string --
int\(0\)
int\(-[1-9][0-9]*\)
int\([1-9][0-9]*\)
-- Testing strncasecmp\(\) with double quoted string --
int\(0\)
int\(-[1-9][0-9]*\)
int\([1-9][0-9]*\)
-- Testing strncasecmp\(\) with here-doc string --
int\(0\)
int\(-[1-9][0-9]*\)
int\([1-9][0-9]*\)
\*\*\* Done \*\*\*
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>