xdiff : remove not needed code
xdiff : update tests to add Exception tests git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4313 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -290,4 +290,50 @@ to this document.
|
|||||||
+\n");
|
+\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_diffFile_unified_1 ()
|
||||||
|
{
|
||||||
|
file_put_contents ("/tmp/test_xdiff1", $this->string1);
|
||||||
|
file_put_contents ("/tmp/test_xdiff2", $this->string2);
|
||||||
|
$xdiff = new xdiff ("unified");
|
||||||
|
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiff2");
|
||||||
|
$this->assertSame ($res, "--- /tmp/test_xdiff1 ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
|
+++ /tmp/test_xdiff2 ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
|
@@ -0,0 +1,6 @@
|
||||||
|
+This is an important
|
||||||
|
+notice! It should
|
||||||
|
+therefore be located at
|
||||||
|
+the beginning of this
|
||||||
|
+document!
|
||||||
|
+
|
||||||
|
@@ -11,5 +16,0 @@
|
||||||
|
-This paragraph contains
|
||||||
|
-text that is outdated.
|
||||||
|
-It will be deleted in the
|
||||||
|
-near future.
|
||||||
|
-
|
||||||
|
@@ -17 +18 @@
|
||||||
|
-check this dokument. On
|
||||||
|
+check this document. On
|
||||||
|
@@ -24,0 +26,4 @@
|
||||||
|
+
|
||||||
|
+This paragraph contains
|
||||||
|
+important new additions
|
||||||
|
+to this document.
|
||||||
|
");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_diffFile_unified_2 ()
|
||||||
|
{
|
||||||
|
$xdiff = new xdiff ("unified");
|
||||||
|
$this->setExpectedException ();
|
||||||
|
$res = $xdiff->diffFile ("/tmp/test_xdiffNOTEXISTS", "/tmp/test_xdiff2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_diffFile_unified_3 ()
|
||||||
|
{
|
||||||
|
$xdiff = new xdiff ("unified");
|
||||||
|
$this->setExpectedException ();
|
||||||
|
$res = $xdiff->diffFile ("/tmp/test_xdiff1", "/tmp/test_xdiffNOTEXISTS");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
xdiff.php
28
xdiff.php
@@ -196,13 +196,6 @@ class xdiff
|
|||||||
if (empty ($chunk1) && ! empty ($chunk2))
|
if (empty ($chunk1) && ! empty ($chunk2))
|
||||||
{
|
{
|
||||||
// APPEND
|
// APPEND
|
||||||
while ($j < count ($array2))
|
|
||||||
{
|
|
||||||
if ($array2[$j] === $lcs)
|
|
||||||
break;
|
|
||||||
$chunk2[] = $array2[$j];
|
|
||||||
$j++;
|
|
||||||
}
|
|
||||||
$diff[] = array ("type" => "Append",
|
$diff[] = array ("type" => "Append",
|
||||||
"startLine1" => $i,
|
"startLine1" => $i,
|
||||||
"endLine1" => $i,
|
"endLine1" => $i,
|
||||||
@@ -214,13 +207,6 @@ class xdiff
|
|||||||
elseif (! empty ($chunk1) && empty ($chunk2))
|
elseif (! empty ($chunk1) && empty ($chunk2))
|
||||||
{
|
{
|
||||||
// DELETE
|
// DELETE
|
||||||
while ($i < count ($array1))
|
|
||||||
{
|
|
||||||
if ($array1[$i] === $lcs)
|
|
||||||
break;
|
|
||||||
$chunk1[] = $array1[$i];
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$diff[] = array ("type" => "Delete",
|
$diff[] = array ("type" => "Delete",
|
||||||
"startLine1" => 1 + $i - count ($chunk1),
|
"startLine1" => 1 + $i - count ($chunk1),
|
||||||
"endLine1" => $i,
|
"endLine1" => $i,
|
||||||
@@ -232,20 +218,6 @@ class xdiff
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// CHANGE ON BOTH ARRAY
|
// CHANGE ON BOTH ARRAY
|
||||||
while ($i < count ($array1))
|
|
||||||
{
|
|
||||||
if ($array1[$i] === $lcs)
|
|
||||||
break;
|
|
||||||
$chunk1[] = $array1[$i];
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
while ($j < count ($array2))
|
|
||||||
{
|
|
||||||
if ($array2[$j] === $lcs)
|
|
||||||
break;
|
|
||||||
$chunk2[] = $array2[$j];
|
|
||||||
$j++;
|
|
||||||
}
|
|
||||||
$diff[] = array ("type" => "Change",
|
$diff[] = array ("type" => "Change",
|
||||||
"startLine1" => 1 + $i - count ($chunk1),
|
"startLine1" => 1 + $i - count ($chunk1),
|
||||||
"endLine1" => $i,
|
"endLine1" => $i,
|
||||||
|
|||||||
Reference in New Issue
Block a user