diff options
Diffstat (limited to 'javaparser-testing/src')
2 files changed, 34 insertions, 2 deletions
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/printer/PrettyPrintVisitorTest.java b/javaparser-testing/src/test/java/com/github/javaparser/printer/PrettyPrintVisitorTest.java index ef2cc0dbf..032ce3dd3 100644 --- a/javaparser-testing/src/test/java/com/github/javaparser/printer/PrettyPrintVisitorTest.java +++ b/javaparser-testing/src/test/java/com/github/javaparser/printer/PrettyPrintVisitorTest.java @@ -192,6 +192,37 @@ public class PrettyPrintVisitorTest { } @Test + public void emptyJavadocGetsFormatted() { + CompilationUnit cu = new CompilationUnit(); + cu.addClass("X").addMethod("abc").setJavadocComment(""); + + assertEqualsNoEol("public class X {\n" + + "\n" + + " /**\n" + + " */\n" + + " void abc() {\n" + + " }\n" + + "}\n", cu.toString()); + } + + @Test + public void multilineJavadocWithLotsOfEmptyLinesGetsFormattedNeatly() { + CompilationUnit cu = new CompilationUnit(); + cu.addClass("X").addMethod("abc").setJavadocComment("\n\n\nab\n\n\ncd\n\n\n"); + + assertEqualsNoEol("public class X {\n" + + "\n" + + " /**\n" + + " * ab\n" + + " *\n" + + " * cd\n" + + " */\n" + + " void abc() {\n" + + " }\n" + + "}\n", cu.toString()); + } + + @Test public void singlelineJavadocGetsFormatted() { CompilationUnit cu = new CompilationUnit(); cu.addClass("X").addMethod("abc").setJavadocComment("line1"); diff --git a/javaparser-testing/src/test/resources/com/github/javaparser/bdd/pretty_printing_scenarios.story b/javaparser-testing/src/test/resources/com/github/javaparser/bdd/pretty_printing_scenarios.story index 50bbe1f50..c3bf46605 100644 --- a/javaparser-testing/src/test/resources/com/github/javaparser/bdd/pretty_printing_scenarios.story +++ b/javaparser-testing/src/test/resources/com/github/javaparser/bdd/pretty_printing_scenarios.story @@ -301,12 +301,13 @@ When the class is parsed by the Java parser Then it is printed as: public class Foo { - /** This line gets duplicated */ + /** + * This line gets duplicated + */ public void foo() { } } - Scenario: various lamba casts (issue 418) Given the class: public class TestLambda { |