Example #1
0
 private String readLine(final byte[] hdrbuf) throws IOException {
   bin.mark(hdrbuf.length);
   final int cnt = bin.read(hdrbuf);
   int lf = 0;
   while (lf < cnt && hdrbuf[lf] != '\n') lf++;
   bin.reset();
   bin.skip(lf);
   if (lf < cnt && hdrbuf[lf] == '\n') bin.skip(1);
   return RawParseUtils.decode(Constants.CHARSET, hdrbuf, 0, lf);
 }
 public void testMatch_TooSmall() {
   final byte[] src = Constants.encodeASCII("author ");
   final byte[] dst = Constants.encodeASCII("author autho");
   assertTrue(RawParseUtils.match(dst, src.length + 1, src) < 0);
 }
 public void testMatch_Prefix() {
   final byte[] src = Constants.encodeASCII("author ");
   final byte[] dst = Constants.encodeASCII("author A. U. Thor");
   assertTrue(RawParseUtils.match(dst, 0, src) == src.length);
   assertTrue(RawParseUtils.match(dst, 1, src) < 0);
 }
 public void testMatch_NotEqual() {
   final byte[] src = Constants.encodeASCII(" differ\n");
   final byte[] dst = Constants.encodeASCII("a differ\n");
   assertTrue(RawParseUtils.match(dst, 2, src) < 0);
 }
 public void testMatch_Equal() {
   final byte[] src = Constants.encodeASCII(" differ\n");
   final byte[] dst = Constants.encodeASCII("foo differ\n");
   assertTrue(RawParseUtils.match(dst, 3, src) == 3 + src.length);
 }