1 package de.fu_berlin.ties.text;
2
3 import junit.framework.TestCase;
4
5 import java.util.Arrays;
6 import java.util.HashMap;
7 import java.util.Map;
8 import java.util.regex.Pattern;
9
10
11 /***
12 * Generated by JUnitDoclet, a tool provided by
13 * ObjectFab GmbH under LGPL.
14 * Please see www.junitdoclet.org, www.gnu.org
15 * and www.objectfab.de for informations about
16 * the tool, the licence and the authors.
17 */
18
19
20 public class TextUtilsTest
21
22 extends TestCase
23
24 {
25
26 TextUtils textutils = null;
27
28
29 public TextUtilsTest(String name) {
30
31 super(name);
32
33 }
34
35 public de.fu_berlin.ties.text.TextUtils createInstance() throws Exception {
36
37 return null;
38
39 }
40
41 protected void setUp() throws Exception {
42
43 super.setUp();
44 textutils = createInstance();
45
46 }
47
48 protected void tearDown() throws Exception {
49
50 textutils = null;
51 super.tearDown();
52
53 }
54
55 public void testCaptureAlternatives() throws Exception {
56
57
58 }
59
60 public void testCountFirst() throws Exception {
61
62
63 }
64
65 public void testCountLast() throws Exception {
66
67
68 }
69
70 public void testEnsurePrintableName() throws Exception {
71
72
73 }
74
75 public void testJoinAlternatives() throws Exception {
76
77
78 }
79
80 public void testMultipleReplaceAll() throws Exception {
81
82 final String[] inputs = {
83 " GNU GENERAL PUBLIC LICENSE\n\n",
84 " Version 2, June 1991\r\n",
85 "\n",
86 " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n",
87 " 59 Temple Place, Suite 330, Boston, MA ",
88 "02111-1307 USA\n",
89 " Everyone is permitted to copy and distribute verbatim copies\r\n",
90 " of this license document, but changing it is not allowed.\n",
91 " \n",
92 "\tPreamble \n",
93 "\n",
94 " The licenses for most software are designed to take away your\r",
95 "freedom",
96 " to share and change it. "
97 };
98
99 final String[] expectedOutputs = {
100 " GNU GENERAL PUBLIC LICENSE\r\n",
101 " Version x, June xxxx\r\n",
102 "\r\n",
103 " Copyright (C) xxxx, xxxx Free Software Foundation, Inc.\r\n",
104 " xx TempLe PLace, Suite xxx, Boston, MA ",
105 "xxxxx-xxxx USA\r\n",
106 " Everyone is permitted to copy and distribute verbatim copies\r\n",
107 " of this License document, but changing it is not aLLowed.\r\n",
108 " \r\n",
109 " PreambLe \r\n",
110 "\r\n",
111 " The Licenses for most software are designed to take away your\r\n",
112 "freedom",
113 " to share and change it. "
114 };
115
116 final Map emptyMap = new HashMap();
117 final Map<Pattern, String> replacements = new HashMap<Pattern, String>();
118 replacements.put(Pattern.compile("[//t ]+"), " ");
119 replacements.put(Pattern.compile("[//r//n]+"), "\r\n");
120 replacements.put(Pattern.compile("//p{Digit}"), "x");
121 replacements.put(Pattern.compile("l"), "L");
122
123 for (int i = 0; i < inputs.length; i++) {
124 assertEquals(TextUtils.multipleReplaceAll(inputs[i], emptyMap),
125 inputs[i]);
126 assertEquals(TextUtils.multipleReplaceAll(inputs[i], replacements),
127 expectedOutputs[i]);
128 }
129
130 }
131
132 public void testNormalize() throws Exception {
133
134
135 }
136
137 public void testReplaceAll() throws Exception {
138
139
140 }
141
142 public void testShorten() throws Exception {
143
144
145 }
146
147 public void testPunctuation() throws Exception {
148
149
150 }
151
152 public void testPunctuationOrSymbol() throws Exception {
153
154
155 }
156
157 public void testSplitLines() throws Exception {
158
159 final String input = " GNU GENERAL PUBLIC LICENSE\n"
160 + " Version 2, June 1991\r\n"
161 + "\n"
162 + " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n"
163 + " 59 Temple Place, Suite 330, Boston, MA "
164 + "02111-1307 USA\n"
165 + " Everyone is permitted to copy and distribute verbatim copies\r\n"
166 + " of this license document, but changing it is not allowed.\n"
167 + " \n"
168 + "\tPreamble \n"
169 + "\n"
170 + " The licenses for most software are designed to take away your\r"
171 + "freedom to share and change it. ";
172
173 final String[] expectedOutput = new String[] {
174 "GNU GENERAL PUBLIC LICENSE",
175 "Version 2, June 1991",
176 "Copyright (C) 1989, 1991 Free Software Foundation, Inc.",
177 "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA",
178 "Everyone is permitted to copy and distribute verbatim copies",
179 "of this license document, but changing it is not allowed.",
180 "Preamble",
181 "The licenses for most software are designed to take away your",
182 "freedom to share and change it."
183 };
184
185 final String[] output = TextUtils.splitLines(input);
186 assertTrue(Arrays.equals(output, expectedOutput));
187
188 }
189
190 public void testSplitLinesExact() throws Exception {
191
192
193 }
194
195 public void testSplitString() throws Exception {
196
197
198 }
199
200 public void testWeaklyNormalize() throws Exception {
201
202
203 }
204
205 public void testWriteln() throws Exception {
206
207
208 }
209
210
211
212 /***
213 * JUnitDoclet moves marker to this method, if there is not match
214 * for them in the regenerated code and if the marker is not empty.
215 * This way, no test gets lost when regenerating after renaming.
216 * Method testVault is supposed to be empty.
217 */
218 public void testVault() throws Exception {
219
220
221 }
222
223 public static void main(String[] args) {
224
225 junit.textui.TestRunner.run(TextUtilsTest.class);
226
227 }
228 }