public void PatchAddContextTest() { diff_match_patchTest dmp = new diff_match_patchTest(); dmp.Patch_Margin = 4; Patch p; p = dmp.PatchFromText("@@ -21,4 +21,10 @@\n-jump\n+somersault\n") [0]; dmp.PatchAddContext(p, "The quick brown fox jumps over the lazy dog."); Assert.AreEqual("@@ -17,12 +17,18 @@\n fox \n-jump\n+somersault\n s ov\n", p.ToString(), "PatchAddContext: Simple case."); p = dmp.PatchFromText("@@ -21,4 +21,10 @@\n-jump\n+somersault\n")[0]; dmp.PatchAddContext(p, "The quick brown fox jumps."); Assert.AreEqual("@@ -17,10 +17,16 @@\n fox \n-jump\n+somersault\n s.\n", p.ToString(), "PatchAddContext: Not enough trailing context."); p = dmp.PatchFromText("@@ -3 +3,2 @@\n-e\n+at\n")[0]; dmp.PatchAddContext(p, "The quick brown fox jumps."); Assert.AreEqual("@@ -1,7 +1,8 @@\n Th\n-e\n+at\n qui\n", p.ToString(), "PatchAddContext: Not enough leading context."); p = dmp.PatchFromText("@@ -3 +3,2 @@\n-e\n+at\n")[0]; dmp.PatchAddContext(p, "The quick brown fox jumps. The quick brown fox crashes."); Assert.AreEqual("@@ -1,27 +1,28 @@\n Th\n-e\n+at\n quick brown fox jumps. \n", p.ToString(), "PatchAddContext: Ambiguity."); }