diff options
Diffstat (limited to 'ext/standard/tests/strings/strncmp_basic.phpt')
| -rw-r--r-- | ext/standard/tests/strings/strncmp_basic.phpt | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/ext/standard/tests/strings/strncmp_basic.phpt b/ext/standard/tests/strings/strncmp_basic.phpt index c0a6bb2532..317039859f 100644 --- a/ext/standard/tests/strings/strncmp_basic.phpt +++ b/ext/standard/tests/strings/strncmp_basic.phpt @@ -7,17 +7,40 @@ Test strncmp() function : basic functionality * Source code: Zend/zend_builtin_functions.c */ -/* Test strncmp() function with all three arguments */ +echo "*** Testing strncmp() function: basic functionality ***\n"; -echo "*** Test strncmp() function: basic functionality ***\n"; +echo "-- Testing strncmp() with single quoted string --\n"; +var_dump( strncmp('Hello', 'Hello', 5) ); //expected: int(0) +var_dump( strncmp('Hello', 'Hi', 5) ); //expected: value < 0 +var_dump( strncmp('Hi', 'Hello', 5) ); //expected: value > 0 + +echo "-- Testing strncmp() with double quoted string --\n"; var_dump( strncmp("Hello", "Hello", 5) ); //expected: int(0) -var_dump( strncmp("Hello", "Hi", 5) ); //expected: int(-1) -var_dump( strncmp("Hi", "Hello", 5) ); //expected: int(1) +var_dump( strncmp("Hello", "Hi", 5) ); //expected: value < 0 +var_dump( strncmp("Hi", "Hello", 5) ); //expected: value > 0 + +echo "-- Testing strncmp() with here-doc string --\n"; +$str = <<<HEREDOC +Hello +HEREDOC; +var_dump( strncmp($str, "Hello", 5) ); //expected: int(0) +var_dump( strncmp($str, "Hi", 5) ); //expected: value < 0 +var_dump( strncmp("Hi", $str, 5) ); //expected: value > 0 + echo "*** Done ***"; ?> ---EXPECTF-- -*** Test strncmp() function: basic functionality *** -int(0) -int(-1) -int(1) -*** Done *** +--EXPECTREGEX-- +\*\*\* Testing strncmp\(\) function: basic functionality \*\*\* +-- Testing strncmp\(\) with single quoted string -- +int\(0\) +int\(-[1-9][0-9]*\) +int\([1-9][0-9]*\) +-- Testing strncmp\(\) with double quoted string -- +int\(0\) +int\(-[1-9][0-9]*\) +int\([1-9][0-9]*\) +-- Testing strncmp\(\) with here-doc string -- +int\(0\) +int\(-[1-9][0-9]*\) +int\([1-9][0-9]*\) +\*\*\* Done \*\*\* |
