package Ġdev . git live . diff lib . patch Ċ Ċ import Ġdev . git live . diff lib . Diff Utils Ċ import Ġjava . util . Arrays Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . fail Ċ import Ġorg . junit . Test Ċ Ċ class ĠPatch Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Diff Exception :: class ) ĊĠĠĠ Ġfun Ġtest Patch _ Insert () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinsert Test _ from Ġ= ĠArrays . asList (" hh h ") ĊĠĠĠĠĠĠĠ Ġval Ġinsert Test _ to Ġ= ĠArrays . asList (" hh h ", Ġ" jj j ", Ġ" kk k ", Ġ" ll l ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpatch Ġ= ĠDiff Utils . diff ( insert Test _ from , Ġinsert Test _ to ) ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( insert Test _ to , ĠDiff Utils . patch ( insert Test _ from , Ġpatch )) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠPatch FailedException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfail ( e . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Diff Exception :: class ) ĊĠĠĠ Ġfun Ġtest Patch _ Delete () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelete Test _ from Ġ= ĠArrays . asList (" ddd ", Ġ" fff ", Ġ" gg g ", Ġ" hh h ") ĊĠĠĠĠĠĠĠ Ġval Ġdelete Test _ to Ġ= ĠArrays . asList (" gg g ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpatch Ġ= ĠDiff Utils . diff ( delete Test _ from , Ġdelete Test _ to ) ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( delete Test _ to , ĠDiff Utils . patch ( delete Test _ from , Ġpatch )) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠPatch FailedException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfail ( e . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Diff Exception :: class ) ĊĠĠĠ Ġfun Ġtest Patch _ Change () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchange Test _ from Ġ= ĠArrays . asList (" aaa ", Ġ" bbb ", Ġ" ccc ", Ġ" ddd ") ĊĠĠĠĠĠĠĠ Ġval Ġchange Test _ to Ġ= ĠArrays . asList (" aaa ", Ġ" b xb ", Ġ" c xc ", Ġ" ddd ") ĊĊĠĠĠĠĠĠĠ Ġval Ġpatch Ġ= ĠDiff Utils . diff ( change Test _ from , Ġchange Test _ to ) ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( change Test _ to , ĠDiff Utils . patch ( change Test _ from , Ġpatch )) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠPatch FailedException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfail ( e . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ } Ċ