Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 189 extra '\0' after indentation indicators #205

Merged
merged 2 commits into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions YamlDotNet.Test/Core/EmitterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ public void BlockCanBeFollowedByDocumentWithCustomTags()
yaml.Should().Contain(Lines("- 'test'", "...", FooTag, ExTag, ExExTag, "--- test"));
}

[Theory]
[InlineData("test", ">-\r\n test\r\n")] // No indentation indicator when no indent.
[InlineData(" test", ">2-\r\n test\r\n")]
public void BlockStyleGeneratesIndentationIndicator(string input, string expected)
{
var events = StreamOf(
DocumentWith(FoldedScalar(input)));

var yaml = EmittedTextFrom(events);

yaml.Should().Be(expected);
}

[Theory]
[InlineData("LF hello\nworld")]
[InlineData("CRLF hello\r\nworld")]
Expand Down
2 changes: 1 addition & 1 deletion YamlDotNet/Core/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ private void WriteBlockScalarHints(string value)

if (analyzer.IsSpace() || analyzer.IsBreak())
{
var indentHint = string.Format(CultureInfo.InvariantCulture, "{0}\0", bestIndent);
var indentHint = string.Format(CultureInfo.InvariantCulture, "{0}", bestIndent);
WriteIndicator(indentHint, false, false, false);
}

Expand Down