// Convert lines down to characters.
ArrayList<String> tmpVector = new ArrayList<String>();
tmpVector.add("");
tmpVector.add("alpha\n");
tmpVector.add("beta\n");
assertLinesToCharsResultEquals("diff_linesToChars: Shared lines.", new LinesToCharsResult("\u0001\u0002\u0001", "\u0002\u0001\u0002", tmpVector), dmp.diff_linesToChars("alpha\nbeta\nalpha\n", "beta\nalpha\nbeta\n"));
tmpVector.clear();
tmpVector.add("");
tmpVector.add("alpha\r\n");
tmpVector.add("beta\r\n");
tmpVector.add("\r\n");
assertLinesToCharsResultEquals("diff_linesToChars: Empty string and blank lines.", new LinesToCharsResult("", "\u0001\u0002\u0003\u0003", tmpVector), dmp.diff_linesToChars("", "alpha\r\nbeta\r\n\r\n\r\n"));
tmpVector.clear();
tmpVector.add("");
tmpVector.add("a");
tmpVector.add("b");
assertLinesToCharsResultEquals("diff_linesToChars: No linebreaks.", new LinesToCharsResult("\u0001", "\u0002", tmpVector), dmp.diff_linesToChars("a", "b"));
// 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(String.valueOf((char) x));
}
assertEquals(n, tmpVector.size());
String lines = lineList.toString();
String chars = charList.toString();
assertEquals(n, chars.length());
tmpVector.add(0, "");
assertLinesToCharsResultEquals("diff_linesToChars: More than 256.", new LinesToCharsResult(chars, "", tmpVector), dmp.diff_linesToChars(lines, ""));
}