SearchProcessorTest Class — netty Architecture
Architecture documentation for the SearchProcessorTest class in SearchProcessorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 77fd8c98_90ee_f735_3303_8eafc0856e0c["SearchProcessorTest"] e59aca67_2461_f589_6281_5e33ad6b15be["SearchProcessorTest.java"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|defined in| e59aca67_2461_f589_6281_5e33ad6b15be 5414cf3b_6b5e_6d68_57e9_fe5f4a309796["testSearch()"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|method| 5414cf3b_6b5e_6d68_57e9_fe5f4a309796 780d2e2f_ba66_d628_03b1_423cb02ef587["testRepeating()"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|method| 780d2e2f_ba66_d628_03b1_423cb02ef587 75931c25_808b_3071_dd43_4ac704b2fa18["testOverlapping()"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|method| 75931c25_808b_3071_dd43_4ac704b2fa18 3c770d97_9fcf_1b3a_02f4_b68f2fe7c0af["testLongInputs()"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|method| 3c770d97_9fcf_1b3a_02f4_b68f2fe7c0af 60a2ca70_34a0_e689_6766_3909f2e06fa3["testUniqueLen64Substrings()"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|method| 60a2ca70_34a0_e689_6766_3909f2e06fa3 1df06349_2b53_77d3_a876_2ebcfcacce5b["SearchProcessorFactory()"] 77fd8c98_90ee_f735_3303_8eafc0856e0c -->|method| 1df06349_2b53_77d3_a876_2ebcfcacce5b
Relationship Graph
Source Code
buffer/src/test/java/io/netty/buffer/search/SearchProcessorTest.java lines 28–167
public class SearchProcessorTest {
private enum Algorithm {
KNUTH_MORRIS_PRATT {
@Override
SearchProcessorFactory newFactory(byte[] needle) {
return AbstractSearchProcessorFactory.newKmpSearchProcessorFactory(needle);
}
},
BITAP {
@Override
SearchProcessorFactory newFactory(byte[] needle) {
return AbstractSearchProcessorFactory.newBitapSearchProcessorFactory(needle);
}
},
AHO_CORASIC {
@Override
SearchProcessorFactory newFactory(byte[] needle) {
return AbstractMultiSearchProcessorFactory.newAhoCorasicSearchProcessorFactory(needle);
}
};
abstract SearchProcessorFactory newFactory(byte[] needle);
}
@ParameterizedTest
@EnumSource(Algorithm.class)
public void testSearch(Algorithm algorithm) {
final ByteBuf haystack = Unpooled.copiedBuffer("abc☺", CharsetUtil.UTF_8);
assertEquals(0, haystack.forEachByte(factory(algorithm, "a").newSearchProcessor()));
assertEquals(1, haystack.forEachByte(factory(algorithm, "ab").newSearchProcessor()));
assertEquals(2, haystack.forEachByte(factory(algorithm, "abc").newSearchProcessor()));
assertEquals(5, haystack.forEachByte(factory(algorithm, "abc☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "abc☺☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "abc☺x").newSearchProcessor()));
assertEquals(1, haystack.forEachByte(factory(algorithm, "b").newSearchProcessor()));
assertEquals(2, haystack.forEachByte(factory(algorithm, "bc").newSearchProcessor()));
assertEquals(5, haystack.forEachByte(factory(algorithm, "bc☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "bc☺☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "bc☺x").newSearchProcessor()));
assertEquals(2, haystack.forEachByte(factory(algorithm, "c").newSearchProcessor()));
assertEquals(5, haystack.forEachByte(factory(algorithm, "c☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "c☺☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "c☺x").newSearchProcessor()));
assertEquals(5, haystack.forEachByte(factory(algorithm, "☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "☺☺").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "☺x").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "z").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "aa").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "ba").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "abcd").newSearchProcessor()));
assertEquals(-1, haystack.forEachByte(factory(algorithm, "abcde").newSearchProcessor()));
haystack.release();
}
@ParameterizedTest
@EnumSource(Algorithm.class)
public void testRepeating(Algorithm algorithm) {
final ByteBuf haystack = Unpooled.copiedBuffer("abcababc", CharsetUtil.UTF_8);
final int length = haystack.readableBytes();
SearchProcessor processor = factory(algorithm, "ab").newSearchProcessor();
assertEquals(1, haystack.forEachByte(processor));
assertEquals(4, haystack.forEachByte(2, length - 2, processor));
assertEquals(6, haystack.forEachByte(5, length - 5, processor));
assertEquals(-1, haystack.forEachByte(7, length - 7, processor));
haystack.release();
}
@ParameterizedTest
@EnumSource(Algorithm.class)
public void testOverlapping(Algorithm algorithm) {
final ByteBuf haystack = Unpooled.copiedBuffer("ababab", CharsetUtil.UTF_8);
final int length = haystack.readableBytes();
SearchProcessor processor = factory(algorithm, "bab").newSearchProcessor();
Source
Frequently Asked Questions
What is the SearchProcessorTest class?
SearchProcessorTest is a class in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/search/SearchProcessorTest.java.
Where is SearchProcessorTest defined?
SearchProcessorTest is defined in buffer/src/test/java/io/netty/buffer/search/SearchProcessorTest.java at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free