All pastes #253241 Raw Edit

Unnamed

public text v1 · immutable
#253241 ·published 2006-11-20 15:24 UTC
rendered paste body
--- 003.phpt_orig	2006-11-20 13:33:11.000000000 +0100
+++ 003.phpt	2006-11-20 13:33:11.000000000 +0100
@@ -3,21 +3,25 @@
 --FILE--
 <?php 
 
-function test_me($title,$expect,$text1,$text2,$cost1=0,$cost2=0,$cost3=0) {
+function test_me($title,$expect,$text1,$text2,$cost1="",$cost2="",$cost3="") {
 
-  if($cost1==0) 
+  if ($cost1=="") { 
 	  $result=levenshtein($text1,$text2);
-	else
+  }
+  elseif ($cost2=="") {
+          $result=levenshtein($text1,$text2,$cost1);
+  }
+  else  {
     $result=levenshtein($text1,$text2,$cost1,$cost2,$cost3);
-
+  }
 	if($result==$expect) return 0;
-
+       
 	echo "$title: result is $result instead of $expect ";
 	echo "for '$text1'/'$text2' ";
 	if($cost1) echo "($cost1:$cost2:$cost3)";
 	echo "\n";
 	
-	return 1;		
+	return 1;
 }
 
 $n=0;
@@ -50,9 +54,21 @@
 $n += test_me("bug #16473", 2, "xax", "xbcx");
 $n += test_me("bug #16473", 2, "ax", "bcx");
 
+$n += test_me("custom", -2, "111", "121", "my_levcode");
+$n += test_me("lt maxlength1", 254, "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsu", "A");
+$n += test_me("gt maxlength1", -1, "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv", "A");
+
+$n += test_me("lt maxlength2", 254, "A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsu");
+$n += test_me("gt maxlength2", -1, "A",  "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv");
 
 echo ($n==0)?"all passed\n":"$n failed\n";
 
 ?>
---EXPECT--
+--EXPECTREGEX--
+
+Warning: levenshtein\(\)\: The general Levenshtein support is not there yet in \S* on line \S*
+
+Warning: levenshtein\(\)\: Argument string\(s\) too long in \S* on line \S*
+
+Warning: levenshtein\(\)\: Argument string\(s\) too long in \S* on line \S*
 all passed