From 93f7ec239373d9e47cb4c83327ceb5813ab06e77 Mon Sep 17 00:00:00 2001 From: rfscholte Date: Fri, 22 Oct 2021 14:50:30 +0200 Subject: [PATCH] Support Text Blocks --- .../com/thoughtworks/qdox/TextBlocksTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/com/thoughtworks/qdox/TextBlocksTest.java diff --git a/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java b/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java new file mode 100644 index 00000000..2fd452df --- /dev/null +++ b/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java @@ -0,0 +1,34 @@ +package com.thoughtworks.qdox; + +import static org.junit.Assert.assertEquals; + +import java.io.StringReader; + +import org.junit.Test; + +import com.thoughtworks.qdox.model.JavaField; +import com.thoughtworks.qdox.model.JavaSource; + +/** + * Examples from https://docs.oracle.com/en/java/javase/16/text-blocks/index.html + * @author Robert Scholte + * + */ +public class TextBlocksTest +{ + private JavaProjectBuilder builder = new JavaProjectBuilder(); + + @Test + public void test() + { + String source = "interface Something { " + + "// Using a text block\r\n" + + "String tbName = \"\"\"\r\n" + + " Pat Q. Smith\"\"\"; }"; + JavaSource javaSource = builder.addSource( new StringReader( source ) ); + JavaField javaField = javaSource.getClasses().get( 0 ).getFieldByName( "tbName" ); + assertEquals( "\"\"\"\r\n" + + " Pat Q. Smith\"\"\"", javaField.getInitializationExpression() ); + } + +}