diff options
author | Vlad Topala <topalavlad@gmail.com> | 2020-01-02 15:18:32 +0200 |
---|---|---|
committer | Egor Andreevich <andreevich.egor@gmail.com> | 2020-01-02 08:18:32 -0500 |
commit | 3d65852a482185e464c4986b862394691ac197da (patch) | |
tree | 42befd0c17555ac31ddfed6004afb3453a4b9bf6 /src/test/java/com/squareup | |
parent | 1225800fdbd05d6a2b069fc1e4949f6461a7236b (diff) | |
download | javapoet-3d65852a482185e464c4986b862394691ac197da.tar.gz |
Hardcoded line separator bug (#684)
* Use regex for new line character to cover both dos and unix endings when calling emitAndIndent - fixes #552
* Update CodeWriter to use linebreak matcher instead of \r\n
Diffstat (limited to 'src/test/java/com/squareup')
-rw-r--r-- | src/test/java/com/squareup/javapoet/CodeWriterTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/java/com/squareup/javapoet/CodeWriterTest.java b/src/test/java/com/squareup/javapoet/CodeWriterTest.java new file mode 100644 index 0000000..331d000 --- /dev/null +++ b/src/test/java/com/squareup/javapoet/CodeWriterTest.java @@ -0,0 +1,23 @@ +package com.squareup.javapoet; + +import org.junit.Test; + +import java.io.IOException; + +import static com.google.common.truth.Truth.assertThat; + +public class CodeWriterTest { + + @Test + public void emptyLineInJavaDocDosEndings() throws IOException { + CodeBlock javadocCodeBlock = CodeBlock.of("A\r\n\r\nB\r\n"); + StringBuilder out = new StringBuilder(); + new CodeWriter(out).emitJavadoc(javadocCodeBlock); + assertThat(out.toString()).isEqualTo( + "/**\n" + + " * A\n" + + " *\n" + + " * B\n" + + " */\n"); + } +}
\ No newline at end of file |