Skip to content

Commit

Permalink
#418 guessIndentation test
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Nov 2, 2020
1 parent 8ee6f1f commit da9cf8a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/test/java/com/amihaiemil/eoyaml/ReadYamlMappingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,35 @@ public void returnsLiteralStringWithStringKey(){
);
}

/**
* ReadYamlMapping returns a literal string mapped to a string key,
* by guessing the different lines' indentation (guessIndentation = true).
*/
@Test
public void returnsLiteralStringWithStringKeyGuessIndentation(){
final List<YamlLine> lines = new ArrayList<>();
lines.add(new RtYamlLine("key: | ", 0));
lines.add(new RtYamlLine(" line1", 1));
lines.add(new RtYamlLine(" line2", 2));
final YamlMapping map = new ReadYamlMapping(
new AllYamlLines(lines), Boolean.TRUE
);
final Collection<String> literalLines = map.literalBlockScalar("key");
MatcherAssert.assertThat(
literalLines.size(),
Matchers.is(2)
);
final Iterator<String> linesIt = literalLines.iterator();
MatcherAssert.assertThat(
linesIt.next(),
Matchers.equalTo("line1")
);
MatcherAssert.assertThat(
linesIt.next(),
Matchers.equalTo(" line2")
);
}

/**
* ReadYamlMapping can return the String mapped to a
* String key.
Expand Down

0 comments on commit da9cf8a

Please sign in to comment.