add UT with timeout for Text#find and fix comments
This commit is contained in:
parent
86bfbe69ab
commit
49ae6cd5d8
|
@ -200,7 +200,7 @@ public class Text extends BinaryComparable
|
|||
while (tgt.hasRemaining()) {
|
||||
if (!src.hasRemaining()) { // src expired first
|
||||
// the remaining bytes in src will always smaller than tgt,
|
||||
// so we can return -1 directory
|
||||
// so we can return -1 directly
|
||||
return -1;
|
||||
}
|
||||
if (!(tgt.get() == src.get())) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
import org.apache.hadoop.thirdparty.com.google.common.base.Charsets;
|
||||
import org.apache.hadoop.thirdparty.com.google.common.primitives.Bytes;
|
||||
|
@ -241,6 +242,17 @@ public class TestText {
|
|||
assertThat(text.find("cd\u20acq")).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test(timeout = 10000)
|
||||
public void testFindWithTimeout() throws Exception {
|
||||
byte[] bytes = new byte[1000000];
|
||||
Arrays.fill(bytes, (byte) 97);
|
||||
String what = new String(bytes);
|
||||
bytes[0] = (byte) 98;
|
||||
Text text = new Text(bytes);
|
||||
|
||||
assertThat(text.find(what)).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindAfterUpdatingContents() throws Exception {
|
||||
Text text = new Text("abcd");
|
||||
|
|
Loading…
Reference in New Issue