Mercurial > hg > RemoteEditor > Eclipse
changeset 171:c61a52e12161
This program is being inspected.
author | tkaito |
---|---|
date | Fri, 29 Aug 2008 22:21:49 +0900 (2008-08-29) |
parents | 86894c5e5fef |
children | a913949a0dd9 |
files | src/pathfinder/mergetest/test/RepCommandOptimizeTest.java |
diffstat | 1 files changed, 31 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pathfinder/mergetest/test/RepCommandOptimizeTest.java Fri Aug 29 18:16:03 2008 +0900 +++ b/src/pathfinder/mergetest/test/RepCommandOptimizeTest.java Fri Aug 29 22:21:49 2008 +0900 @@ -22,6 +22,17 @@ Integer.toString(REP.REPCMD_DELETE),"?","1","8" }; + static String[] test2 = { + Integer.toString(REP.REPCMD_INSERT),"C","2","1", + Integer.toString(REP.REPCMD_INSERT),"B","3","2", + Integer.toString(REP.REPCMD_INSERT),"d","2","3", + Integer.toString(REP.REPCMD_INSERT),"B","3","4", + Integer.toString(REP.REPCMD_DELETE),"A","3","5", + Integer.toString(REP.REPCMD_DELETE),"A","1","6", + Integer.toString(REP.REPCMD_INSERT),"d","3","7", + Integer.toString(REP.REPCMD_DELETE),"d","1","8" + +}; static private String[] text1d = { "aaa", "bbb", "ccc", "ddd", "eee", @@ -57,9 +68,10 @@ } } - LinkedList<REPCommand> optimize(LinkedList<REPCommand> input){ + LinkedList<REPCommand> optimize(LinkedList<REPCommand> inp){ LinkedList<REPCommand> output = new LinkedList<REPCommand>(); - output = reverse(input); + output = reverse(inp); + for(int i = 0; i < output.size(); i++){ REPCommand r = output.get(i); switch(r.cmd){ @@ -116,34 +128,33 @@ if(ln < o.lineno) i++; } if(i == opt.size()){ - for(int j = 0; j < opt.size(); j++){ - REPCommand c = opt.get(j); + for(REPCommand c : opt){ c.lineno -= 1; } } } - void printCmdList(LinkedList<REPCommand> before, LinkedList<REPCommand> after){ - System.out.println("---------- CmdList1 ----------"); + void printCmdList(LinkedList<REPCommand> before){ + System.out.println("---------- CmdList ----------"); for(REPCommand r: before){ System.out.println(r.toString()); } - System.out.println("---------- CmdList2 ----------"); + /*System.out.println("---------- CmdList2 ----------"); for(REPCommand s: after){ System.out.println(s.toString()); - } + }*/ } - Text text1 = new Text(text1d); - Text text2 = new Text(text2d); + static Text text1 = new Text(text1d); + static Text text2 = new Text(text2d); - void edit(LinkedList<REPCommand> before, LinkedList<REPCommand> after){ + void edit(LinkedList<REPCommand> before, Text txt){ for(REPCommand r : before){ - text1.edit(r); + txt.edit(r); } - for(REPCommand s : after){ + /*for(REPCommand s : after){ text2.edit(s); - } + }*/ } void printText(){ @@ -166,10 +177,12 @@ public static void main(String[] s){ RepCommandOptimizeTest rco = new RepCommandOptimizeTest(); - rco.makeCommand(test1); - //java.util.Collections.shuffle(cmdlist); - rco.printCmdList(cmdlist, rco.optimize(cmdlist)); - rco.edit(cmdlist, rco.optimize(cmdlist)); + rco.makeCommand(test2); + java.util.Collections.shuffle(cmdlist); + rco.printCmdList(cmdlist); + rco.edit(cmdlist,text1); + rco.printCmdList(rco.optimize(cmdlist)); + rco.edit(rco.optimize(cmdlist),text2); rco.printText(); rco.checkText(); }