aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Somov <public.somov@gmail.com>2022-09-02 14:02:30 +0300
committerAndrey Somov <public.somov@gmail.com>2022-09-02 14:02:30 +0300
commit26fa6cdba5be1a5c05fce534995c76f1f01315a5 (patch)
treefe52a83271d1dd63c4111cb24f335613a3fa2c8f
parentc7ae960bb310cc74ef9087ff6c64f485d6b44bad (diff)
downloadsnakeyaml-26fa6cdba5be1a5c05fce534995c76f1f01315a5.tar.gz
Update DoubleQuoteTest
-rw-r--r--src/test/java/org/yaml/snakeyaml/issues/issue544/DoubleQuoteTest.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue544/DoubleQuoteTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue544/DoubleQuoteTest.java
index c50b09d3..31c870ba 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue544/DoubleQuoteTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue544/DoubleQuoteTest.java
@@ -32,8 +32,7 @@ import org.yaml.snakeyaml.nodes.Tag;
public class DoubleQuoteTest {
- @Test
- public void test() {
+ private MappingNode create() {
String content = "🔐This process is simple and secure.";
ScalarNode doubleQuotedKey = new ScalarNode(Tag.STR, "double_quoted", null, null,
@@ -54,13 +53,18 @@ public class DoubleQuoteTest {
MappingNode mappingNode = new MappingNode(Tag.MAP, nodeTuples, FlowStyle.BLOCK);
+ return mappingNode;
+ }
+
+ @Test
+ public void testUnicode() {
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setAllowUnicode(true);
Yaml yaml = new Yaml(dumperOptions);
StringWriter writer = new StringWriter();
- yaml.serialize(mappingNode, writer);
+ yaml.serialize(create(), writer);
String output = writer.toString();
String expectedOutput = "double_quoted: \"🔐This process is simple and secure.\"\n"
@@ -68,4 +72,21 @@ public class DoubleQuoteTest {
assertEquals(expectedOutput, output);
}
+
+ @Test
+ public void testSubstitution() {
+ DumperOptions dumperOptions = new DumperOptions();
+ dumperOptions.setAllowUnicode(false); // substitute with U notation
+
+ Yaml yaml = new Yaml(dumperOptions);
+
+ StringWriter writer = new StringWriter();
+ yaml.serialize(create(), writer);
+
+ String output = writer.toString();
+ String expectedOutput = "double_quoted: \"\\U0001f510This process is simple and secure.\"\n"
+ + "single_quoted: \"\\U0001f510This process is simple and secure.\"\n";
+
+ assertEquals(expectedOutput, output);
+ }
}