mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
c1a06704da
Casting a huge unsigned value to signed is implementation-defined behavior in C. By introducing the ZEND_THREEWAY_COMPARE() macro, we can sidestep this integer overflow/underflow/casting problem.
30 lines
598 B
PHP
30 lines
598 B
PHP
--TEST--
|
|
strncasecmp() tests
|
|
--FILE--
|
|
<?php
|
|
|
|
try {
|
|
var_dump(strncasecmp("", "", -1));
|
|
} catch (\ValueError $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
|
|
var_dump(strncasecmp("aef", "dfsgbdf", 0));
|
|
var_dump(strncasecmp("aef", "dfsgbdf", 10));
|
|
var_dump(strncasecmp("qwe", "qwer", 3));
|
|
var_dump(strncasecmp("qwerty", "QweRty", 6));
|
|
var_dump(strncasecmp("qwErtY", "qwer", 7));
|
|
var_dump(strncasecmp("q123", "Q123", 3));
|
|
var_dump(strncasecmp("01", "01", 1000));
|
|
|
|
?>
|
|
--EXPECT--
|
|
strncasecmp(): Argument #3 ($length) must be greater than or equal to 0
|
|
int(0)
|
|
int(-3)
|
|
int(0)
|
|
int(0)
|
|
int(1)
|
|
int(0)
|
|
int(0)
|