Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ bld/
[Bb]in/
[Oo]bj/

# JetBrains Rider
.idea/

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down
28 changes: 28 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Text/CommentOnEndOfTheLine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace ValveKeyValue.Test
{
class CommentOnEndOfTheLine
{
[Test]
public void CanHandleCommentOnEndOfTheLine()
{
var text = new StringBuilder();
text.Append(@"""test_kv""" + "\n");
text.Append("{" + "\n");
text.Append("//" + "\n");
text.Append(@"""test"" ""hello""" + "\n");
text.Append("}" + "\n");

var data = KVSerializer.Create(KVSerializationFormat.KeyValues1Text).Deserialize(text.ToString());

Assert.Multiple(() =>
{
Assert.That(data.Children.Count(), Is.EqualTo(1));
Assert.That((string)data["test"], Is.EqualTo("hello"));
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ KVToken ReadComment()
sb.Append(next);
}

if (sb[^1] == '\r')
if (sb.Length > 0 && sb[^1] == '\r')
{
sb.Remove(sb.Length - 1, 1);
}
Expand Down