aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/squareup
diff options
context:
space:
mode:
authorVlad Topala <topalavlad@gmail.com>2020-01-02 15:18:32 +0200
committerEgor Andreevich <andreevich.egor@gmail.com>2020-01-02 08:18:32 -0500
commit3d65852a482185e464c4986b862394691ac197da (patch)
tree42befd0c17555ac31ddfed6004afb3453a4b9bf6 /src/test/java/com/squareup
parent1225800fdbd05d6a2b069fc1e4949f6461a7236b (diff)
downloadjavapoet-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.java23
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