mirror of
https://github.com/php/php-src.git
synced 2026-03-28 02:02:32 +01:00
Port similar_text test to 5.2. Tested on Windows, Linux and Linux 64 bit
This commit is contained in:
44
ext/standard/tests/strings/similar_text_basic.phpt
Normal file
44
ext/standard/tests/strings/similar_text_basic.phpt
Normal file
@@ -0,0 +1,44 @@
|
||||
--TEST--
|
||||
similar_text(), basic tests
|
||||
--CREDITS--
|
||||
Mats Lindh <mats at lindh.no>
|
||||
#Testfest php.no
|
||||
--INI--
|
||||
precision=14
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int similar_text(string str1, string str2 [, float percent])
|
||||
* Description: Calculates the similarity between two strings
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
echo "\n-- Basic calls with just two strings --\n";
|
||||
var_dump(similar_text("abcdefgh", "efg"));
|
||||
var_dump(similar_text("abcdefgh", "mno"));
|
||||
var_dump(similar_text("abcdefghcc", "c"));
|
||||
var_dump(similar_text("abcdefghabcdef", "zzzzabcdefggg"));
|
||||
|
||||
echo "\n-- Same calls with precentage return variable specified --\n";
|
||||
$percent = 0;
|
||||
similar_text("abcdefgh", "efg", $percent);
|
||||
var_dump($percent);
|
||||
similar_text("abcdefgh", "mno", $percent);
|
||||
var_dump($percent);
|
||||
similar_text("abcdefghcc", "c", $percent);
|
||||
var_dump($percent);
|
||||
similar_text("abcdefghabcdef", "zzzzabcdefggg", $percent);
|
||||
var_dump($percent);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
-- Basic calls with just two strings --
|
||||
int(3)
|
||||
int(0)
|
||||
int(1)
|
||||
int(7)
|
||||
|
||||
-- Same calls with precentage return variable specified --
|
||||
float(54.545454545455)
|
||||
float(0)
|
||||
float(18.181818181818)
|
||||
float(51.851851851852)
|
||||
===DONE===
|
||||
29
ext/standard/tests/strings/similar_text_error.phpt
Normal file
29
ext/standard/tests/strings/similar_text_error.phpt
Normal file
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
similar_text(), error tests for missing parameters
|
||||
--CREDITS--
|
||||
Mats Lindh <mats at lindh.no>
|
||||
#Testfest php.no
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : proto int similar_text(string str1, string str2 [, float percent])
|
||||
* Description: Calculates the similarity between two strings
|
||||
* Source code: ext/standard/string.c
|
||||
*/
|
||||
|
||||
$extra_arg = 10;
|
||||
echo "\n-- Testing similar_text() function with more than expected no. of arguments --\n";
|
||||
similar_text("abc", "def", $percent, $extra_arg);
|
||||
|
||||
echo "\n-- Testing similar_text() function with less than expected no. of arguments --\n";
|
||||
similar_text("abc");
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
-- Testing similar_text() function with more than expected no. of arguments --
|
||||
|
||||
Warning: Wrong parameter count for similar_text() in %s on line %d
|
||||
|
||||
-- Testing similar_text() function with less than expected no. of arguments --
|
||||
|
||||
Warning: Wrong parameter count for similar_text() in %s on line %d
|
||||
===DONE===
|
||||
Reference in New Issue
Block a user