ByteSequenceCompiler { public ByteSequence compile(final String droidExpression) throws CompileException { return compile(droidExpression, ByteSequenceAnchor.BOFOffset, CompileType.DROID); }  ByteSequence compile(final String droidExpression); ByteSequence compile(final String droidExpression, final ByteSequenceAnchor anchor); ByteSequence compile(final String droidExpression,
                                final ByteSequenceAnchor anchor,
                                final CompileType compileType); void compile(final ByteSequence sequence, final String droidExpression); void compile(final ByteSequence sequence, final String droidExpression, ByteSequenceAnchor anchor); void compile(final ByteSequence sequence,
                        final String droidExpression,
                        final ByteSequenceAnchor anchor,
                        final CompileType compileType); void compile(final ByteSequence sequence,
                        final String droidExpression,
                        final CompileType compileType); static final ByteSequenceCompiler COMPILER; }
@Test(expected = IllegalArgumentException.class) public void testNullSequence() throws Exception { COMPILER.compile(null); }
@Test(expected = CompileException.class) public void testBadSyntaxSequence() throws Exception { COMPILER.compile("01 02 03 this doesn't make any sense"); }
@Test public void testEmptySequence() throws Exception { ByteSequence seq = COMPILER.compile(""); assertTrue(seq.getNumberOfSubSequences() == 0); }
@Test public void testWhitespaceOnlySequence() throws Exception { ByteSequence seq = COMPILER.compile(" \t\t \n \r \t"); assertTrue(seq.getNumberOfSubSequences() == 0); }
@Test public void testBOFReference() throws Exception { ByteSequence seq = COMPILER.compile("00", BOFOffset, DROID); assertEquals("BOFoffset", seq.getReference()); assertTrue(seq.isAnchoredToBOF()); assertFalse(seq.isAnchoredToEOF()); ByteSequence newSeq = new ByteSequence(); COMPILER.compile(newSeq, "00", BOFOffset, DROID); assertEquals("BOFoffset", newSeq.getReference()); assertTrue(newSeq.isAnchoredToBOF()); assertFalse(newSeq.isAnchoredToEOF()); }
@Test public void testEOFReference() throws Exception { ByteSequence seq = COMPILER.compile("00", EOFOffset, DROID); assertEquals("EOFoffset", seq.getReference()); assertFalse(seq.isAnchoredToBOF()); assertTrue(seq.isAnchoredToEOF()); ByteSequence newSeq = new ByteSequence(); COMPILER.compile(newSeq, "00", EOFOffset, DROID); assertEquals("EOFoffset", newSeq.getReference()); assertFalse(newSeq.isAnchoredToBOF()); assertTrue(newSeq.isAnchoredToEOF()); }
@Test public void testVariableReference() throws Exception { ByteSequence seq = COMPILER.compile("00", ByteSequenceAnchor.VariableOffset, DROID); assertEquals("Variable", seq.getReference()); assertFalse(seq.isAnchoredToBOF()); assertFalse(seq.isAnchoredToEOF()); ByteSequence newSeq = new ByteSequence(); COMPILER.compile(newSeq, "00", ByteSequenceAnchor.VariableOffset, DROID); assertEquals("Variable", newSeq.getReference()); assertFalse(newSeq.isAnchoredToBOF()); assertFalse(newSeq.isAnchoredToEOF()); }
@Test public void testAny() throws Exception { ByteSequence seq = COMPILER.compile("??"); SubSequence sub = assertSingleSubSequenceNoFragments(seq); assertSingleByteMatcher(sub.getAnchorMatcher(), AnyByteMatcher.class); }