mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
PHP Testfest. Tests done by Felix De Vliegher
This commit is contained in:
parent
8cb2c1da19
commit
82830dd06f
51
ext/standard/tests/strings/strnatcasecmp_basic.phpt
Normal file
51
ext/standard/tests/strings/strnatcasecmp_basic.phpt
Normal file
@ -0,0 +1,51 @@
|
||||
--TEST--
|
||||
Test strnatcasecmp() function : basic functionality
|
||||
--CREDITS--
|
||||
Felix De Vliegher <felix.devliegher@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int strnatcasecmp(string s1, string s2)
|
||||
* Description: Returns the result of case-insensitive string comparison using 'natural' algorithm
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
function str_dump($one, $two) {
|
||||
var_dump(strnatcasecmp($one, $two));
|
||||
}
|
||||
|
||||
echo "*** Testing strnatcasecmp() : basic functionality ***\n";
|
||||
|
||||
// Calling strnatcasecmp() with all possible arguments
|
||||
str_dump('A', 'a');
|
||||
str_dump('a10', 'A20');
|
||||
str_dump('A1b', 'a');
|
||||
str_dump('x2-y7', 'x8-y8');
|
||||
str_dump('1.010', '1.001');
|
||||
str_dump(' ab', ' aB');
|
||||
str_dump('acc ', 'acc');
|
||||
str_dump(11.5, 10.5);
|
||||
str_dump(10.5, 10.5E1);
|
||||
str_dump('Rfc822.txt', 'rfc2086.txt');
|
||||
str_dump('Rfc822.txt', 'rfc822.TXT');
|
||||
str_dump('pIc 6', 'pic 7');
|
||||
str_dump(0xFFF, 0Xfff);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing strnatcasecmp() : basic functionality ***
|
||||
int(0)
|
||||
int(-1)
|
||||
int(1)
|
||||
int(-1)
|
||||
int(1)
|
||||
int(0)
|
||||
int(1)
|
||||
int(1)
|
||||
int(-1)
|
||||
int(-1)
|
||||
int(0)
|
||||
int(-1)
|
||||
int(0)
|
||||
===DONE===
|
58
ext/standard/tests/strings/strnatcasecmp_variation1.phpt
Normal file
58
ext/standard/tests/strings/strnatcasecmp_variation1.phpt
Normal file
@ -0,0 +1,58 @@
|
||||
--TEST--
|
||||
Test strnatcasecmp() function : variation
|
||||
--CREDITS--
|
||||
Felix De Vliegher <felix.devliegher@gmail.com>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : int strnatcasecmp(string s1, string s2)
|
||||
* Description: Returns the result of case-insensitive string comparison using 'natural' algorithm
|
||||
* Source code: ext/standard/string.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
/* Preparation */
|
||||
class a
|
||||
{
|
||||
function __toString()
|
||||
{
|
||||
return "Hello WORLD";
|
||||
}
|
||||
}
|
||||
|
||||
class b
|
||||
{
|
||||
function __toString()
|
||||
{
|
||||
return "HELLO world";
|
||||
}
|
||||
}
|
||||
|
||||
$a = new a();
|
||||
$b = new b();
|
||||
|
||||
function str_dump($a, $b) {
|
||||
var_dump(strnatcasecmp($a, $b));
|
||||
}
|
||||
|
||||
echo "*** Testing strnatcasecmp() : variation ***\n";
|
||||
|
||||
str_dump(chr(128), chr(255));
|
||||
str_dump('0', false);
|
||||
str_dump('fooBar', '');
|
||||
str_dump('', -1);
|
||||
str_dump("Hello\0world", "Helloworld");
|
||||
str_dump("\x0", "\0");
|
||||
str_dump($a, $b);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
*** Testing strnatcasecmp() : variation ***
|
||||
int(-1)
|
||||
int(1)
|
||||
int(6)
|
||||
int(-2)
|
||||
int(-1)
|
||||
int(0)
|
||||
int(0)
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user