### Question:
VorbisUtil { public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header, boolean quiet) throws ParserException { if (header.bytesLeft() < 7) { if (quiet) { return false; } else { throw new ParserException("too short header: " + header.bytesLeft()); } } if (header.readUnsignedByte() != headerType) { if (quiet) { return false; } else { throw new ParserException("expected header type " + Integer.toHexString(headerType)); } } if (!(header.readUnsignedByte() == 'v' && header.readUnsignedByte() == 'o' && header.readUnsignedByte() == 'r' && header.readUnsignedByte() == 'b' && header.readUnsignedByte() == 'i' && header.readUnsignedByte() == 's')) { if (quiet) { return false; } else { throw new ParserException("expected characters 'vorbis'"); } } return true; } private  VorbisUtil(); static int iLog(int x); static VorbisIdHeader readVorbisIdentificationHeader(ParsableByteArray headerData); static CommentHeader readVorbisCommentHeader(ParsableByteArray headerData); static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header,
      boolean quiet); static Mode[] readVorbisModes(ParsableByteArray headerData, int channels);  }### Answer:
@Test public void testVerifyVorbisHeaderCapturePattern() throws ParserException { ParsableByteArray header = new ParsableByteArray( new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x01, header, false)).isTrue(); }
@Test public void testVerifyVorbisHeaderCapturePatternInvalidHeader() { ParsableByteArray header = new ParsableByteArray( new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); try { VorbisUtil.verifyVorbisHeaderCapturePattern(0x99, header, false); fail(); } catch (ParserException e) { assertThat(e.getMessage()).isEqualTo("expected header type 99"); } }
@Test public void testVerifyVorbisHeaderCapturePatternInvalidHeaderQuite() throws ParserException { ParsableByteArray header = new ParsableByteArray( new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x99, header, true)).isFalse(); }
@Test public void testVerifyVorbisHeaderCapturePatternInvalidPattern() { ParsableByteArray header = new ParsableByteArray( new byte[] {0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's'}); try { VorbisUtil.verifyVorbisHeaderCapturePattern(0x01, header, false); fail(); } catch (ParserException e) { assertThat(e.getMessage()).isEqualTo("expected characters 'vorbis'"); } }
@Test public void testVerifyVorbisHeaderCapturePatternQuiteInvalidPatternQuite() throws ParserException { ParsableByteArray header = new ParsableByteArray( new byte[] {0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x01, header, true)).isFalse(); }