11package com .github .difflib .text ;
22
33import com .github .difflib .algorithm .DiffException ;
4+ import java .io .File ;
5+ import java .io .IOException ;
6+ import java .nio .file .Files ;
47import java .util .Arrays ;
58import java .util .List ;
69import java .util .regex .Pattern ;
10+ import static java .util .stream .Collectors .toList ;
711import static org .junit .Assert .assertEquals ;
812import static org .junit .Assert .assertTrue ;
913import org .junit .Test ;
@@ -263,7 +267,7 @@ public void testGeneratorUnchanged() throws DiffException {
263267assertEquals ("[CHANGE, ,]" ,rows .get (1 ).toString ());
264268assertEquals ("[EQUAL,other,other]" ,rows .get (2 ).toString ());
265269 }
266-
270+
267271@ Test
268272public void testGeneratorIssue14 ()throws DiffException {
269273DiffRowGenerator generator =DiffRowGenerator .create ()
@@ -282,4 +286,33 @@ public void testGeneratorIssue14() throws DiffException {
282286assertEquals (1 ,rows .size ());
283287assertEquals ("~J. G. Feldstein~**T. P. Pastor**, Chair" ,rows .get (0 ).getOldLine ());
284288 }
289+
290+ @ Test
291+ public void testGeneratorIssue15 ()throws DiffException ,IOException {
292+ DiffRowGenerator generator =DiffRowGenerator .create ()
293+ .showInlineDiffs (true )//show the ~ ~ and ** ** symbols on each difference
294+ .inlineDiffByWord (true )//show the ~ ~ and ** ** around each different word instead of each letter
295+ //.reportLinesUnchanged(true) //experiment
296+ .oldTag (f ->"~" )
297+ .newTag (f ->"**" )
298+ .build ();
299+
300+ List <String >listOne =Files .lines (new File ("target/test-classes/mocks/issue15_1.txt" ).toPath ())
301+ .collect (toList ());
302+
303+ List <String >listTwo =Files .lines (new File ("target/test-classes/mocks/issue15_2.txt" ).toPath ())
304+ .collect (toList ());
305+
306+ List <DiffRow >rows =generator .generateDiffRows (listOne ,listTwo );
307+
308+ assertEquals (9 ,rows .size ());
309+
310+ for (DiffRow row :rows ) {
311+ System .out .println ("|" +row .getOldLine () +"| " +row .getNewLine () +" |" );
312+ if (!row .getOldLine ().startsWith ("TABLE_NAME" )) {
313+ assertTrue (row .getNewLine ().startsWith ("**ACTIONS_C16913**" ));
314+ assertTrue (row .getOldLine ().startsWith ("~ACTIONS_C1700" ));
315+ }
316+ }
317+ }
285318}