Skip to content

Commit

Permalink
add unittest for multiline literalBlockStyle with trailing space Fast…
Browse files Browse the repository at this point in the history
  • Loading branch information
njank committed Oct 3, 2024
1 parent af83ff7 commit 05c42bf
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.fasterxml.jackson.dataformat.yaml.failing;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
Expand Down Expand Up @@ -32,4 +34,22 @@ public void testStartMarkerViaMapper() throws Exception
.trim();
assertEquals("key: \"value\"", output);
}

public void testLiteralBlockStyleMultilineWithTrailingSpace() throws Exception
{
YAMLFactory f = new YAMLFactory();
// verify default settings
assertFalse(f.isEnabled(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE));

YAMLMapper mapper = YAMLMapper.builder()
.configure(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE, true)
.build();

Map<String, Object> content = new HashMap<String, Object>();
content.put("text", "Hello\nWorld ");
String yaml = mapper.writeValueAsString(content).trim();

assertEquals("---\n" +
"text: |-\n Hello\n World ", yaml);
}
}

0 comments on commit 05c42bf

Please sign in to comment.