public void diff_charsToLinesTest() {
diff_match_patchTest dmp = new diff_match_patchTest();
// Convert chars up to lines.
List<Diff> diffs = new List<Diff> {
new Diff(Operation.EQUAL, "\u0001\u0002\u0001"),
new Diff(Operation.INSERT, "\u0002\u0001\u0002")};
List<string> tmpVector = new List<string>();
tmpVector.Add("");
tmpVector.Add("alpha\n");
tmpVector.Add("beta\n");
dmp.diff_charsToLines(diffs, tmpVector);
CollectionAssert.AreEqual(new List<Diff> {
new Diff(Operation.EQUAL, "alpha\nbeta\nalpha\n"),
new Diff(Operation.INSERT, "beta\nalpha\nbeta\n")}, diffs);
// More than 256 to reveal any 8-bit limitations.
int n = 300;
tmpVector.Clear();
StringBuilder lineList = new StringBuilder();
StringBuilder charList = new StringBuilder();
for (int x = 1; x < n + 1; x++) {
tmpVector.Add(x + "\n");
lineList.Append(x + "\n");
charList.Append(Convert.ToChar (x));
}
Assert.AreEqual(n, tmpVector.Count);
string lines = lineList.ToString();
string chars = charList.ToString();
Assert.AreEqual(n, chars.Length);
tmpVector.Insert(0, "");
diffs = new List<Diff> {new Diff(Operation.DELETE, chars)};
dmp.diff_charsToLines(diffs, tmpVector);
CollectionAssert.AreEqual(new List<Diff>
{new Diff(Operation.DELETE, lines)}, diffs);
}