### Question:
JavadocScannerUtil { public static int countUntilBlockEnd(JavadocScanner scanner, int start) { int offset = 0; while (true) { JavadocTokenKind kind = scanner.lookahead(start + offset).getKind(); if (kind == JavadocTokenKind.LEFT_BRACE) { offset++; JavadocTokenKind la = scanner.lookahead(start + offset).getKind(); if (la == JavadocTokenKind.AT) { offset++; offset += countUntil(S_RIGHT_BRACE, scanner, start + offset); } } else if (kind == JavadocTokenKind.LINE_BREAK) { offset += countUntilNextPrintable(scanner, start + offset); JavadocTokenKind la = scanner.lookahead(start + offset).getKind(); if (la == JavadocTokenKind.AT) { return offset; } } else if (kind == JavadocTokenKind.EOF) { return offset; } else { offset++; } } } private  JavadocScannerUtil(); static List<JavadocToken> lookaheadTokens(JavadocScanner scanner, int start, int count); static int countWhile(Collection<JavadocTokenKind> kinds, JavadocScanner scanner, int start); static int countUntil(Collection<JavadocTokenKind> kinds, JavadocScanner scanner, int start); static int countUntilBlockEnd(JavadocScanner scanner, int start); static int countUntilCommentEnd(JavadocScanner scanner, boolean returnMinusIfMissing, int start); static int countUntilNextPrintable(JavadocScanner scanner, int start); static int countUntilNextLineStart(JavadocScanner scanner, int start); static int consumeLineEnd(JavadocScanner scanner, boolean multiline);  }### Answer:
@Test public void testCountUntilBlockEnd() { { DefaultJavadocScanner scanner = string("Hello, world!"); int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 0); assertEquals(EOF, scanner.lookahead(count).getKind()); } { DefaultJavadocScanner scanner = string( "Hello, world!\n" + "@stop"); int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 0); assertEquals(AT, scanner.lookahead(count).getKind()); assertEquals("stop", scanner.lookahead(count + 1).getText()); } { DefaultJavadocScanner scanner = string( "\n" + " * Hello, world!\n" + " * @stop"); int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 0); assertEquals(AT, scanner.lookahead(count).getKind()); assertEquals("stop", scanner.lookahead(count + 1).getText()); } { DefaultJavadocScanner scanner = string( "\n" + " * Hello, world!\n" + " * @stop"); int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 0); assertEquals(AT, scanner.lookahead(count).getKind()); assertEquals("stop", scanner.lookahead(count + 1).getText()); } { DefaultJavadocScanner scanner = string( "\n" + " * {@code block start-->\n" + " * @dummy\n" + " * }\n" + " * @stop"); int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 0); assertEquals(AT, scanner.lookahead(count).getKind()); assertEquals("stop", scanner.lookahead(count + 1).getText()); } { DefaultJavadocScanner scanner = string( "\n" + " * @start\n" + " * {@code block start-->\n" + " * @dummy\n" + " * }\n" + " * @stop"); int count = JavadocScannerUtil.countUntilBlockEnd(scanner, 6); assertEquals(AT, scanner.lookahead(6 + count).getKind()); assertEquals("stop", scanner.lookahead(6 + count + 1).getText()); } }