Update xdiff to not display the ,1 if the length is 1 on unified mode. Add the unit tests
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4311 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -155,12 +155,27 @@ to this document.
|
|||||||
|
|
||||||
public function test_diff_normal_5 ()
|
public function test_diff_normal_5 ()
|
||||||
{
|
{
|
||||||
// Mode normal
|
|
||||||
$xdiff = new xdiff ();
|
$xdiff = new xdiff ();
|
||||||
$res = $xdiff->diff ("\n", "\n");
|
$res = $xdiff->diff ("\n", "\n");
|
||||||
$this->assertSame ($res, "");
|
$this->assertSame ($res, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_diff_normal_6 ()
|
||||||
|
{
|
||||||
|
$xdiff = new xdiff ();
|
||||||
|
$res = $xdiff->diff ("\n", "");
|
||||||
|
$this->assertSame ($res, "1d0
|
||||||
|
< \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_diff_normal_7 ()
|
||||||
|
{
|
||||||
|
$xdiff = new xdiff ();
|
||||||
|
$res = $xdiff->diff ("", "\n");
|
||||||
|
$this->assertSame ($res, "0a1
|
||||||
|
> \n");
|
||||||
|
}
|
||||||
|
|
||||||
public function test_diff_unified_1 ()
|
public function test_diff_unified_1 ()
|
||||||
{
|
{
|
||||||
// Mode unified
|
// Mode unified
|
||||||
@@ -255,4 +270,24 @@ to this document.
|
|||||||
$this->assertSame ($res, "");
|
$this->assertSame ($res, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_diff_unified_6 ()
|
||||||
|
{
|
||||||
|
$xdiff = new xdiff ("unified");
|
||||||
|
$res = $xdiff->diff ("\n", "");
|
||||||
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
|
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
|
@@ -1 +0,0 @@
|
||||||
|
-\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_diff_unified_7 ()
|
||||||
|
{
|
||||||
|
$xdiff = new xdiff ("unified");
|
||||||
|
$res = $xdiff->diff ("", "\n");
|
||||||
|
$this->assertSame ($res, "--- Original ".date ("Y-m-d H:i:s.u000 O")."
|
||||||
|
+++ New ".date ("Y-m-d H:i:s.u001 O")."
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,7 +285,8 @@ class xdiff
|
|||||||
$info .= ",0";
|
$info .= ",0";
|
||||||
$info .= " +";
|
$info .= " +";
|
||||||
$info .= $diff["startLine2"];
|
$info .= $diff["startLine2"];
|
||||||
$info .= ",".$diff["length"];
|
if ($diff["length"] !== 1)
|
||||||
|
$info .= ",".$diff["length"];
|
||||||
$info .= " @@\n";
|
$info .= " @@\n";
|
||||||
$d .= $info;
|
$d .= $info;
|
||||||
$d .= "+".implode ("+", $diff["chunk"]);
|
$d .= "+".implode ("+", $diff["chunk"]);
|
||||||
@@ -294,7 +295,8 @@ class xdiff
|
|||||||
{
|
{
|
||||||
$info = "@@ -";
|
$info = "@@ -";
|
||||||
$info .= $diff["startLine1"];
|
$info .= $diff["startLine1"];
|
||||||
$info .= ",".$diff["length"];
|
if ($diff["length"] !== 1)
|
||||||
|
$info .= ",".$diff["length"];
|
||||||
$info .= " +";
|
$info .= " +";
|
||||||
$info .= $diff["startLine2"];
|
$info .= $diff["startLine2"];
|
||||||
$info .= ",0";
|
$info .= ",0";
|
||||||
|
|||||||
Reference in New Issue
Block a user