1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.util; |
21 |
|
|
22 |
|
import junit.framework.TestCase; |
23 |
|
|
24 |
|
|
25 |
|
@version |
26 |
|
@since |
27 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (46) |
Complexity: 9 |
Complexity Density: 0.24 |
|
28 |
|
public class ListBuilderTest extends TestCase |
29 |
|
{ |
30 |
|
|
31 |
|
@param |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
33 |
1 |
public ListBuilderTest(String name)... |
34 |
|
{ |
35 |
1 |
super(name); |
36 |
|
} |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
38 |
1 |
public void testTwo() throws Exception... |
39 |
|
{ |
40 |
1 |
testTwo("a", "<A><a></a></A>"); |
41 |
1 |
testTwo("a\na", "<A><a></a><a></a></A>"); |
42 |
1 |
testTwo("a\n a", "<A><a><A><a></a></A></a></A>"); |
43 |
1 |
testTwo("a\n a\n a", "<A><a><A><a></a><a></a></A></a></A>"); |
44 |
1 |
testTwo("a\n a\n a\n a", "<A><a>" |
45 |
|
+ "<A>" |
46 |
|
+ "<a></a>" |
47 |
|
+ "<a></a>" |
48 |
|
+ "<a></a>" |
49 |
|
+ "</A>" |
50 |
|
+ "</a></A>"); |
51 |
1 |
testTwo("a\n b\n b\n b", "<A><a>" |
52 |
|
+ "<B>" |
53 |
|
+ "<b></b>" |
54 |
|
+ "<b></b>" |
55 |
|
+ "<b></b>" |
56 |
|
+ "</B>" |
57 |
|
+ "</a></A>"); |
58 |
1 |
testTwo("a\n b\n b\n b\na", "<A>" |
59 |
|
+ "<a>" |
60 |
|
+ "<B>" |
61 |
|
+ "<b></b>" |
62 |
|
+ "<b></b>" |
63 |
|
+ "<b></b>" |
64 |
|
+ "</B>" |
65 |
|
+ "</a>" |
66 |
|
+ "<a></a>" |
67 |
|
+ "</A>"); |
68 |
1 |
testTwo("a\nab\nabc\nabcd", "<A><a>" |
69 |
|
+ "<B><b>" |
70 |
|
+ "<C><c>" |
71 |
|
+ "<D><d></d></D>" |
72 |
|
+ "</c></C>" |
73 |
|
+ "</b></B>" |
74 |
|
+ "</a></A>"); |
75 |
1 |
testTwo("a\nab\nabc", "<A><a>" |
76 |
|
+ "<B><b>" |
77 |
|
+ "<C><c></c></C>" |
78 |
|
+ "</b></B>" |
79 |
|
+ "</a></A>"); |
80 |
1 |
testTwo("" |
81 |
|
+ " a\n" |
82 |
|
+ " a b\n" |
83 |
|
+ " a c\n" |
84 |
|
+ " a c d\n" |
85 |
|
+ " e" |
86 |
|
+ "" |
87 |
|
+ "" |
88 |
|
+ "" |
89 |
|
+ "" |
90 |
|
+ "", "<A><a>" |
91 |
|
+ "<B><b></b></B>" |
92 |
|
+ "<C><c>" |
93 |
|
+ "<D><d></d></D>" |
94 |
|
+ "</c></C>" |
95 |
|
+ "</a></A>" |
96 |
|
+ "<E><e></e></E>"); |
97 |
|
|
98 |
1 |
testTwo("a\n b", "<A><a><B><b></b></B></a></A>"); |
99 |
1 |
testTwo("a\nab", "<A><a><B><b></b></B></a></A>"); |
100 |
1 |
testTwo("a\n ", "<A><a></a></A>"); |
101 |
1 |
testTwo(" ", ""); |
102 |
1 |
testTwo("", ""); |
103 |
1 |
testTwo(" ", ""); |
104 |
1 |
testTwo(" a", "<A><a></a></A>"); |
105 |
1 |
testTwo(" a \n ", "<A><a></a></A>"); |
106 |
1 |
testTwo("" |
107 |
|
+ " a\n" |
108 |
|
+ " b\n" |
109 |
|
+ " c\n" |
110 |
|
+ " d\n" |
111 |
|
+ " e" |
112 |
|
+ "" |
113 |
|
+ "" |
114 |
|
+ "" |
115 |
|
+ "" |
116 |
|
+ "", "<A><a>" |
117 |
|
+ "<B><b></b></B>" |
118 |
|
+ "<C><c>" |
119 |
|
+ "<D><d></d></D>" |
120 |
|
+ "</c></C>" |
121 |
|
+ "</a></A>" |
122 |
|
+ "<E><e></e></E>"); |
123 |
1 |
testTwo("" |
124 |
|
+ "a\n" |
125 |
|
+ "ab\n" |
126 |
|
+ "ac\n" |
127 |
|
+ "acd\n" |
128 |
|
+ "e" |
129 |
|
+ "" |
130 |
|
+ "" |
131 |
|
+ "" |
132 |
|
+ "" |
133 |
|
+ "", "<A><a>" |
134 |
|
+ "<B><b></b></B>" |
135 |
|
+ "<C><c>" |
136 |
|
+ "<D><d></d></D>" |
137 |
|
+ "</c></C>" |
138 |
|
+ "</a></A>" |
139 |
|
+ "<E><e></e></E>"); |
140 |
1 |
testTwo("" |
141 |
|
+ " a\n" |
142 |
|
+ " a b\n" |
143 |
|
+ " a c\n" |
144 |
|
+ " a c d\n" |
145 |
|
+ " e" |
146 |
|
+ "" |
147 |
|
+ "" |
148 |
|
+ "" |
149 |
|
+ "" |
150 |
|
+ "", "<A><a>" |
151 |
|
+ "<B><b></b></B>" |
152 |
|
+ "<C><c>" |
153 |
|
+ "<D><d></d></D>" |
154 |
|
+ "</c></C>" |
155 |
|
+ "</a></A>" |
156 |
|
+ "<E><e></e></E>"); |
157 |
|
|
158 |
1 |
testTwo("" + " a\n" + " b\n" + " c\n" + "cd\n" + "", "" |
159 |
|
+ "<A><a></a></A>" |
160 |
|
+ "<B><b></b></B>" |
161 |
|
+ "<C><c>" |
162 |
|
+ "<D><d></d></D>" |
163 |
|
+ "</c></C>"); |
164 |
|
} |
165 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
166 |
22 |
private void testTwo(String string, String control)... |
167 |
|
{ |
168 |
22 |
final StringBuffer buf = new StringBuffer(); |
169 |
22 |
IListListener listener = new IListListener() |
170 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
171 |
59 |
public void beginRow(char treeType, char rowType)... |
172 |
|
{ |
173 |
59 |
openTag(rowType); |
174 |
|
} |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
176 |
50 |
public void beginTree(char type)... |
177 |
|
{ |
178 |
50 |
openTag(Character.toUpperCase(type)); |
179 |
|
} |
180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
181 |
109 |
private void closeTag(char ch)... |
182 |
|
{ |
183 |
109 |
buf.append("</").append(ch).append(">"); |
184 |
|
} |
185 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
186 |
59 |
public void endRow(char treeType, char rowType)... |
187 |
|
{ |
188 |
59 |
closeTag(rowType); |
189 |
|
} |
190 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
50 |
public void endTree(char type)... |
192 |
|
{ |
193 |
50 |
closeTag(Character.toUpperCase(type)); |
194 |
|
} |
195 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
196 |
109 |
private void openTag(char str)... |
197 |
|
{ |
198 |
109 |
buf.append("<").append(str).append(">"); |
199 |
|
} |
200 |
|
}; |
201 |
22 |
ListBuilder builder = new ListBuilder(listener); |
202 |
22 |
String[] lines = string.split("\n"); |
203 |
22 |
for (String s : lines) { |
204 |
64 |
builder.alignContext(s); |
205 |
|
} |
206 |
22 |
builder.alignContext(""); |
207 |
|
|
208 |
22 |
assertEquals(control, buf.toString()); |
209 |
|
} |
210 |
|
} |