-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for multiline literalBlockStyle with trailing space #366 (
#501)
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
.../src/test/java/com/fasterxml/jackson/dataformat/yaml/failing/SimpleGeneration366Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.fasterxml.jackson.dataformat.yaml.failing; | ||
|
||
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class SimpleGeneration366Test extends ModuleTestBase | ||
{ | ||
// [dataformats-text#366]: multiline literal block with trailing spaces does not work | ||
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); | ||
} | ||
|
||
// [dataformats-text#366]: multiline literal block without trailing spaces actually works | ||
public void testLiteralBlockStyleMultiline() 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); | ||
} | ||
} |