]> granicus.if.org Git - php/commitdiff
PHP Testfest. Tests done by Felix De Vliegher
authorDavid Soria Parra <dsp@php.net>
Thu, 10 Jul 2008 23:46:49 +0000 (23:46 +0000)
committerDavid Soria Parra <dsp@php.net>
Thu, 10 Jul 2008 23:46:49 +0000 (23:46 +0000)
ext/standard/tests/strings/strnatcasecmp_basic.phpt [new file with mode: 0644]
ext/standard/tests/strings/strnatcasecmp_variation1.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/strings/strnatcasecmp_basic.phpt b/ext/standard/tests/strings/strnatcasecmp_basic.phpt
new file mode 100644 (file)
index 0000000..d385c19
--- /dev/null
@@ -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===
diff --git a/ext/standard/tests/strings/strnatcasecmp_variation1.phpt b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt
new file mode 100644 (file)
index 0000000..c211170
--- /dev/null
@@ -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===