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 testCountFirst() throws Exception {
56
57
58 }
59
60 public void testCountLast() throws Exception {
61
62
63 }
64
65 public void testEnsurePrintableName() throws Exception {
66
67
68 }
69
70 public void testJoinAlternatives() throws Exception {
71
72
73 }
74
75 public void testMultipleReplaceAll() throws Exception {
76
77 final String[] inputs = {
78 " GNU GENERAL PUBLIC LICENSE\n\n",
79 " Version 2, June 1991\r\n",
80 "\n",
81 " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n",
82 " 59 Temple Place, Suite 330, Boston, MA ",
83 "02111-1307 USA\n",
84 " Everyone is permitted to copy and distribute verbatim copies\r\n",
85 " of this license document, but changing it is not allowed.\n",
86 " \n",
87 "\tPreamble \n",
88 "\n",
89 " The licenses for most software are designed to take away your\r",
90 "freedom",
91 " to share and change it. "
92 };
93
94 final String[] expectedOutputs = {
95 " GNU GENERAL PUBLIC LICENSE\r\n",
96 " Version x, June xxxx\r\n",
97 "\r\n",
98 " Copyright (C) xxxx, xxxx Free Software Foundation, Inc.\r\n",
99 " xx TempLe PLace, Suite xxx, Boston, MA ",
100 "xxxxx-xxxx USA\r\n",
101 " Everyone is permitted to copy and distribute verbatim copies\r\n",
102 " of this License document, but changing it is not aLLowed.\r\n",
103 " \r\n",
104 " PreambLe \r\n",
105 "\r\n",
106 " The Licenses for most software are designed to take away your\r\n",
107 "freedom",
108 " to share and change it. "
109 };
110
111 final Map emptyMap = new HashMap();
112 final Map<Pattern, String> replacements = new HashMap<Pattern, String>();
113 replacements.put(Pattern.compile("[//t ]+"), " ");
114 replacements.put(Pattern.compile("[//r//n]+"), "\r\n");
115 replacements.put(Pattern.compile("//p{Digit}"), "x");
116 replacements.put(Pattern.compile("l"), "L");
117
118 for (int i = 0; i < inputs.length; i++) {
119 assertEquals(TextUtils.multipleReplaceAll(inputs[i], emptyMap),
120 inputs[i]);
121 assertEquals(TextUtils.multipleReplaceAll(inputs[i], replacements),
122 expectedOutputs[i]);
123 }
124
125 }
126
127 public void testNormalize() throws Exception {
128
129
130 }
131
132 public void testReplaceAll() throws Exception {
133
134
135 }
136
137 public void testShorten() throws Exception {
138
139
140 }
141
142 public void testPunctuation() throws Exception {
143
144
145 }
146
147 public void testPunctuationOrSymbol() throws Exception {
148
149
150 }
151
152 public void testSplitLines() throws Exception {
153
154 final String input = " GNU GENERAL PUBLIC LICENSE\n"
155 + " Version 2, June 1991\r\n"
156 + "\n"
157 + " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n"
158 + " 59 Temple Place, Suite 330, Boston, MA "
159 + "02111-1307 USA\n"
160 + " Everyone is permitted to copy and distribute verbatim copies\r\n"
161 + " of this license document, but changing it is not allowed.\n"
162 + " \n"
163 + "\tPreamble \n"
164 + "\n"
165 + " The licenses for most software are designed to take away your\r"
166 + "freedom to share and change it. ";
167
168 final String[] expectedOutput = new String[] {
169 "GNU GENERAL PUBLIC LICENSE",
170 "Version 2, June 1991",
171 "Copyright (C) 1989, 1991 Free Software Foundation, Inc.",
172 "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA",
173 "Everyone is permitted to copy and distribute verbatim copies",
174 "of this license document, but changing it is not allowed.",
175 "Preamble",
176 "The licenses for most software are designed to take away your",
177 "freedom to share and change it."
178 };
179
180 final String[] output = TextUtils.splitLines(input);
181 assertTrue(Arrays.equals(output, expectedOutput));
182
183 }
184
185 public void testSplitLinesExact() throws Exception {
186
187
188 }
189
190 public void testSplitString() throws Exception {
191
192
193 }
194
195
196
197 /***
198 * JUnitDoclet moves marker to this method, if there is not match
199 * for them in the regenerated code and if the marker is not empty.
200 * This way, no test gets lost when regenerating after renaming.
201 * Method testVault is supposed to be empty.
202 */
203 public void testVault() throws Exception {
204
205
206 }
207
208 public static void main(String[] args) {
209
210 junit.textui.TestRunner.run(TextUtilsTest.class);
211
212 }
213 }