Skip to content

Commit

Permalink
Support Text Blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
rfscholte committed Oct 22, 2021
1 parent 7506dd2 commit 93f7ec2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/com/thoughtworks/qdox/TextBlocksTest.java
Original file line number Diff line number Diff line change
@@ -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 <a href="https://docs.oracle.com/en/java/javase/16/text-blocks/index.html">https://docs.oracle.com/en/java/javase/16/text-blocks/index.html</a>
* @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() );
}

}

0 comments on commit 93f7ec2

Please # to comment.