use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilTest method testInvalidTags.
@Test
public void testInvalidTags() {
final String[] text = { "/** @fake block", " * {@bogus inline}", " * {@link List valid}" };
final Comment comment = new Comment(text, 1, 3, text[2].length());
final JavadocTags allTags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL);
assertWithMessage("Unexpected invalid tags size").that(allTags.getInvalidTags()).hasSize(2);
assertTag("Unexpected invalid tag", new InvalidJavadocTag(1, 4, "fake"), allTags.getInvalidTags().get(0));
assertTag("Unexpected invalid tag", new InvalidJavadocTag(2, 4, "bogus"), allTags.getInvalidTags().get(1));
assertWithMessage("Unexpected valid tags size").that(allTags.getValidTags()).hasSize(1);
assertTag("Unexpected valid tag", new JavadocTag(3, 4, "link", "List valid"), allTags.getValidTags().get(0));
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilTest method testBlockTag.
@Test
public void testBlockTag() {
final String[] text = { "/** @see elsewhere ", " */" };
final Comment comment = new Comment(text, 1, 4, text[1].length());
final JavadocTags allTags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL);
assertWithMessage("Invalid valid tags size").that(allTags.getValidTags()).hasSize(1);
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilsTest method testInlineTagLinkText.
@Test
public void testInlineTagLinkText() {
final String[] text = { "/** {@link List link text }" };
final Comment comment = new Comment(text, 1, 1, text[0].length());
final List<JavadocTag> tags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL).getValidTags();
assertEquals("List link text", tags.get(0).getFirstArg());
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilsTest method testTagType.
@Test
public void testTagType() {
final String[] text = { "/** @see block", " * {@link List inline}, {@link List#add(Object)}" };
final Comment comment = new Comment(text, 1, 2, text[1].length());
final JavadocTags blockTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.BLOCK);
final JavadocTags inlineTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.INLINE);
assertEquals(1, blockTags.getValidTags().size());
assertEquals(2, inlineTags.getValidTags().size());
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilsTest method testInvalidTags.
@Test
public void testInvalidTags() {
final String[] text = { "/** @fake block", " * {@bogus inline}", " * {@link List valid}" };
final Comment comment = new Comment(text, 1, 3, text[2].length());
final JavadocTags allTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL);
assertEquals(2, allTags.getInvalidTags().size());
assertEquals(1, allTags.getValidTags().size());
}
Aggregations