Skip to content

Commit 9f850d5

Browse files
committed
Add test for inline comments in section names
1 parent 73a180f commit 9f850d5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Tests/SimpleConfigTest.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,32 @@ public void GetValueOrDefault()
713713
Assert.AreEqual(setting.GetValue(typeof(ulong)), 7654321);
714714
}
715715

716+
[Test]
717+
public void TestCommentsInSectionNames()
718+
{
719+
var previous = Configuration.IgnoreInlineComments;
720+
Configuration.IgnoreInlineComments = true;
721+
722+
var cfg = new Configuration();
723+
cfg.Add("SomeSection1#NotAComment");
724+
cfg.Add(new Section("SomeSection2# also part of the section's name"));
725+
726+
cfg["SomeSection1#NotAComment"].Add("Setting", 1);
727+
cfg["SomeSection2# also part of the section's name"].Add("Setting", 2);
728+
729+
TestWithFile(filename =>
730+
{
731+
cfg.SaveToFile(filename);
732+
733+
var parsedCfg = Configuration.LoadFromFile(filename);
734+
735+
Assert.AreEqual("SomeSection1#NotAComment", parsedCfg[0].Name);
736+
Assert.AreEqual("SomeSection2# also part of the section's name", parsedCfg[1].Name);
737+
});
738+
739+
Configuration.IgnoreInlineComments = previous;
740+
}
741+
716742
private static void TestWithFile(Action<string> action)
717743
{
718744
string filename = Path.GetTempFileName();

0 commit comments

Comments
 (0)