]> granicus.if.org Git - php/commitdiff
Add test for strnatcmp() align left cases
authorSol Richardson <srichardson@i3logix.com>
Wed, 4 Oct 2017 20:27:20 +0000 (14:27 -0600)
committerJoe Watkins <krakjoe@php.net>
Thu, 19 Oct 2017 11:11:03 +0000 (12:11 +0100)
ext/standard/tests/strings/strnatcmp_leftalign.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/strings/strnatcmp_leftalign.phpt b/ext/standard/tests/strings/strnatcmp_leftalign.phpt
new file mode 100644 (file)
index 0000000..31eed64
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Test strnatcmp() function : left align, whitespace, digits
+--CREDIT--
+Sol Richardson <sr5732358@hotmail.com>
+--FILE--
+<?php
+/* Prototype  : int strnatcmp  ( string $str1  , string $str2  )
+* Description: String comparisons using a "natural order" algorithm
+* Source code: ext/standard/string.c
+*/
+
+echo "-- Testing strnatcmp() function whitespace, left-align, digit --\n";
+echo "-- Leading whitespace, digits, string 1 longer --\n";
+$str1 = " 00";
+$str2 = " 0";
+var_dump( strnatcmp( $str1, $str2) );
+
+echo "-- Leading whitespace, digits, string 2 longer --\n";
+$str1 = " 0";
+$str2 = " 00";
+var_dump( strnatcmp( $str1, $str2) );
+?>
+
+--EXPECTF--
+-- Testing strnatcmp() function whitespace, left-align, digit --
+-- Leading whitespace, digits, string 1 longer --
+int(1)
+-- Leading whitespace, digits, string 2 longer --
+int(-1)