Mercurial > hg > RemoteEditor > REPSessionManager
comparison test/RepCommandOptimizeTest.java @ 387:6f356d160e58
IPv6 any address
author | one@firefly.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 10 Nov 2008 22:21:52 +0900 |
parents | f9fa876d3539 |
children | f8916a96a373 |
comparison
equal
deleted
inserted
replaced
386:bba62c4ac323 | 387:6f356d160e58 |
---|---|
1 package test; | 1 package test; |
2 | |
3 import static org.junit.Assert.*; | |
2 | 4 |
3 import java.util.LinkedList; | 5 import java.util.LinkedList; |
4 import java.util.List; | 6 import java.util.List; |
7 | |
8 import org.junit.Test; | |
5 | 9 |
6 import rep.REPCommand; | 10 import rep.REPCommand; |
7 import rep.REP; | 11 import rep.REP; |
8 import rep.optimizers.NullOptimizer; | 12 import rep.optimizers.NullOptimizer; |
9 import rep.optimizers.DeleteInsertOptimizer; | 13 import rep.optimizers.DeleteInsertOptimizer; |
83 | 87 |
84 public static void printText(Text text){ | 88 public static void printText(Text text){ |
85 text.printAllText(); | 89 text.printAllText(); |
86 } | 90 } |
87 | 91 |
92 | |
88 public static void main(String[] s){ | 93 public static void main(String[] s){ |
94 RepCommandOptimizeTest t = new RepCommandOptimizeTest(); | |
95 t.main0(); | |
96 } | |
97 | |
98 @Test | |
99 public void main0(){ | |
100 | |
89 REPCommandOptimizer rco; | 101 REPCommandOptimizer rco; |
90 | 102 |
91 if (true) rco = new DeleteInsertOptimizer(); // | 103 if (true) rco = new DeleteInsertOptimizer(); // |
92 else rco = new NullOptimizer(); // なにも最適化しない | 104 else rco = new NullOptimizer(); // なにも最適化しない |
93 | 105 |
105 } | 117 } |
106 System.out.println("Errors "+err+"/"+total+"."); | 118 System.out.println("Errors "+err+"/"+total+"."); |
107 | 119 |
108 } | 120 } |
109 | 121 |
110 | |
111 private static void test(REPCommandOptimizer rco, List<REPCommand> cmdlist, | 122 private static void test(REPCommandOptimizer rco, List<REPCommand> cmdlist, |
112 Text text1, Text text2) { | 123 Text text1, Text text2) { |
113 List<REPCommand> result; // optimize | 124 List<REPCommand> result; // optimize |
114 // this command list is applied to a text. and print the text. | 125 // this command list is applied to a text. and print the text. |
115 text1.edit(cmdlist); | 126 text1.edit(cmdlist); |
116 result = rco.optimize(cmdlist); | 127 result = rco.optimize(cmdlist); |
117 // this command list applied to other text, and print it. | 128 // this command list applied to other text, and print it. |
118 text2.edit(result); | 129 text2.edit(result); |
119 // check two texts. | 130 // check two texts. |
131 assertEquals(text1.equals(text2),true); | |
120 if(!text1.equals(text2)){ | 132 if(!text1.equals(text2)){ |
121 System.out.println("two texts not match"); | 133 System.out.println("two texts not match"); |
122 print(cmdlist, result, text1, text2); | 134 print(cmdlist, result, text1, text2); |
123 err++; | 135 err++; |
124 } | 136 } |