Skip to content

Commit 26951aa

Browse files
committed
Add testSpeedCheckAZ
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1155040 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0c0c692 commit 26951aa

1 file changed

Lines changed: 32 additions & 13 deletions

File tree

src/test/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,10 @@ public void testSetRuleTypeToRulesIllegalArgumentException() {
165165
}
166166

167167
/**
168-
* Runs between 1.1 and 13 seconds at length 40 for me (Gary Gregory, 2011/08/06)
168+
* (Un)luckily, the worse performing test because of the data in {@link TEST_CHARS}
169169
*
170170
* @throws EncoderException
171171
*/
172-
@Test(/* timeout = 20000L */)
173-
public void testSpeedCheckRandom() throws EncoderException {
174-
BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
175-
StringBuffer stringBuffer = new StringBuffer();
176-
Random rand = new Random();
177-
stringBuffer.append(TEST_CHARS[rand.nextInt(TEST_CHARS.length)]);
178-
for (int i = 0; i < 40; i++) {
179-
bmpm.encode(stringBuffer.toString());
180-
stringBuffer.append(TEST_CHARS[rand.nextInt(TEST_CHARS.length)]);
181-
}
182-
}
183-
184172
@Test(/* timeout = 20000L */)
185173
public void testSpeedCheck() throws EncoderException {
186174
BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
@@ -194,4 +182,35 @@ public void testSpeedCheck() throws EncoderException {
194182
stringBuffer.append(TEST_CHARS[j]);
195183
}
196184
}
185+
186+
/**
187+
* Another odd performance edge case.
188+
*
189+
* @throws EncoderException
190+
*/
191+
@Test(/* timeout = 20000L */)
192+
public void testSpeedCheckAZ() throws EncoderException {
193+
BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
194+
String phrase = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
195+
for (int i = 1; i <= phrase.length(); i++) {
196+
bmpm.encode(phrase.subSequence(0, i));
197+
}
198+
}
199+
200+
/**
201+
* Runs between 1.6 and 13 seconds at length 40 for me (Gary Gregory, 2011/08/06)
202+
*
203+
* @throws EncoderException
204+
*/
205+
@Test(/* timeout = 20000L */)
206+
public void testSpeedCheckRandom() throws EncoderException {
207+
BeiderMorseEncoder bmpm = this.createGenericApproxEncoder();
208+
StringBuffer stringBuffer = new StringBuffer();
209+
Random rand = new Random();
210+
stringBuffer.append(TEST_CHARS[rand.nextInt(TEST_CHARS.length)]);
211+
for (int i = 0; i < 40; i++) {
212+
bmpm.encode(stringBuffer.toString());
213+
stringBuffer.append(TEST_CHARS[rand.nextInt(TEST_CHARS.length)]);
214+
}
215+
}
197216
}

0 commit comments

Comments
 (0)