summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/strncasecmp_error.phpt
blob: f120f4af8200fa3fb18fa6624be69ed407337828 (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
--TEST--
Test strncasecmp() function : error conditions
--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: error conditions ***\n";
$str1 = 'string_val';
$str2 = 'string_val';

echo "-- Testing strncasecmp() function with invalid argument --\n";
$len = -10;

try {
    var_dump( strncasecmp($str1, $str2, $len) );
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}

?>
--EXPECT--
*** Testing strncasecmp() function: error conditions ***
-- Testing strncasecmp() function with invalid argument --
strncasecmp(): Argument #3 ($len) must be greater than or equal to 0