Skip to content

Commit

Permalink
added tests to ensure ToString and table iterator function properly
Browse files Browse the repository at this point in the history
  • Loading branch information
John Kidd Jr committed Jun 6, 2023
1 parent c85cb43 commit d485db0
Show file tree
Hide file tree
Showing 4 changed files with 841 additions and 667 deletions.
14 changes: 14 additions & 0 deletions Tomlet.Tests/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,19 @@ public void SerializingPathStringsPrefersLiterals()

Assert.Equal($"myString = '{myString}'", document.SerializedValue.Trim());
}

[Fact]
public void StringValueIsSameAsToString()
{
var document = GetDocument(TestResources.StringEqualsToStringInput);

Assert.Collection(document.Entries.Values,
entry => Assert.Equal(Assert.IsType<TomlString>(entry).StringValue, Assert.IsType<TomlString>(entry).ToString()),
entry => Assert.Equal(Assert.IsType<TomlString>(entry).StringValue, Assert.IsType<TomlString>(entry).ToString()),
entry => Assert.Equal(Assert.IsType<TomlString>(entry).StringValue, Assert.IsType<TomlString>(entry).ToString()),
entry => Assert.Equal(Assert.IsType<TomlLong>(entry).StringValue, Assert.IsType<TomlLong>(entry).ToString()),
entry => Assert.Equal(Assert.IsType<TomlLong>(entry).StringValue, Assert.IsType<TomlLong>(entry).ToString())
);
}
}
}
20 changes: 20 additions & 0 deletions Tomlet.Tests/TableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,25 @@ public void TablesCanHaveQuotedDottedNames()

Assert.Equal("pug", document.GetSubTable("dog").GetSubTable("tater.man").GetSubTable("type").GetString("name"));
}

[Fact]
public void TableIteratorEqualsEntries()
{
var document = GetDocument(TestResources.TableIteratorInput);

Assert.Single(document.Entries);

Assert.NotNull(document.GetSubTable("table-1"));

var table1 = document.GetSubTable("table-1");

Assert.Equal(4, table1.Entries.Count);

foreach (var entry in table1)
{
Assert.True(table1.Entries.ContainsKey(entry.Key));
Assert.Equal(table1.Entries[entry.Key], entry.Value);
}
}
}
}
Loading

0 comments on commit d485db0

Please sign in to comment.