# HG changeset patch # User tkaito # Date 1220091810 -32400 # Node ID 48542404f832eb65a1869adc7c31c87bd0fcdf8c # Parent bf0ca6c4383457aa8b03cd7aa51870c8b5de410b Provisional version diff -r bf0ca6c43834 -r 48542404f832 src/pathfinder/mergetest/test/RepCommandOptimizeTest.java --- a/src/pathfinder/mergetest/test/RepCommandOptimizeTest.java Sat Aug 30 19:15:40 2008 +0900 +++ b/src/pathfinder/mergetest/test/RepCommandOptimizeTest.java Sat Aug 30 19:23:30 2008 +0900 @@ -14,12 +14,22 @@ static String[] test1 = { Integer.toString(REP.REPCMD_DELETE),"d","1","1", Integer.toString(REP.REPCMD_INSERT),"B","3","2", - Integer.toString(REP.REPCMD_INSERT),"B","3","3", - Integer.toString(REP.REPCMD_INSERT),"C","2","4", - Integer.toString(REP.REPCMD_DELETE),"d","3","5", - Integer.toString(REP.REPCMD_DELETE),"d","2","6", - Integer.toString(REP.REPCMD_INSERT),"A","3","7", - Integer.toString(REP.REPCMD_INSERT),"A","1","8" + Integer.toString(REP.REPCMD_INSERT),"B","1","3", + Integer.toString(REP.REPCMD_INSERT),"C","3","4", + Integer.toString(REP.REPCMD_DELETE),"d","13","5", + Integer.toString(REP.REPCMD_DELETE),"d","3","6", + Integer.toString(REP.REPCMD_DELETE),"d","1","7", + Integer.toString(REP.REPCMD_INSERT),"A","5","8", + Integer.toString(REP.REPCMD_DELETE),"d","1","9", + Integer.toString(REP.REPCMD_DELETE),"d","1","10", + Integer.toString(REP.REPCMD_INSERT),"B","10","11", + Integer.toString(REP.REPCMD_INSERT),"B","1","12", + Integer.toString(REP.REPCMD_INSERT),"C","3","13", + Integer.toString(REP.REPCMD_DELETE),"d","2","14", + Integer.toString(REP.REPCMD_DELETE),"d","3","15", + Integer.toString(REP.REPCMD_DELETE),"d","1","16", + Integer.toString(REP.REPCMD_INSERT),"A","3","17", + Integer.toString(REP.REPCMD_DELETE),"d","1","18" }; static private String[] text1d = { @@ -66,7 +76,7 @@ case REP.REPCMD_INSERT: break; case REP.REPCMD_DELETE: - optimizedAddDelete(output,r,i); + optimizedAdd(output,r,i); break; } } @@ -80,7 +90,7 @@ } return reverse; } - private void optimizedAddDelete(LinkedList output, REPCommand r, int ln) { + private void optimizedAdd(LinkedList output, REPCommand r, int ln) { int lineno = r.lineno; int minln = output.size(); for(int i = ln; i < output.size(); i++){ @@ -95,21 +105,19 @@ lineNumberCorrection(output,minln,i,ln); output.remove(r); output.remove(s); + ln--; break; - } - + } }else if(s.cmd==REP.REPCMD_DELETE){ if(s.lineno < lineno){ lineno ++; - //System.out.println("eid = " + r.eid + "lineno = " + lineno); } }else{ System.out.println("There are no such commands."); } } - } - + private void lineNumberCorrection(LinkedList opt, int ln, int count, int r){ for(int i = r; i < count; i++){ REPCommand o = opt.get(i); @@ -122,6 +130,7 @@ for(REPCommand r: before){ System.out.println(r.toString()); } + System.out.println("Total = " + before.size()); } static Text text1 = new Text(text1d); @@ -140,13 +149,16 @@ text2.printAllText(); } - void checkText(){ + void check(LinkedList before, LinkedList after){ + int diff; System.out.println("----------- Check -----------"); if(!text1.equals(text2)){ System.out.println("It isn't equal."); }else{ System.out.println("Equal."); } + diff = before.size() - after.size(); + System.out.println("difference = " + diff); } @@ -162,7 +174,8 @@ result = rco.optimize(cmdlist); rco.printCmdList(result); rco.edit(result,text2); + rco.printText(); - rco.checkText(); + rco.check(cmdlist,result); } }