Skip to content

Commit

Permalink
Add support for unsigned integral data types
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Sandu committed Jun 23, 2019
1 parent d9a8773 commit 3342716
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Mustachio.Tests/TemplateFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Mustachio.Tests
{
public class TemplateFixture
{

[Fact]
public void TemplateRendersContentWithNoVariables()
{
Expand Down Expand Up @@ -71,6 +71,17 @@ public void NegationGroupRendersContentWhenValueNotSet()
Assert.Equal("No Stuff Here.", rendered);
}

[Fact]
public void UnsignedIntegralTypeModelVariablesAreSupported()
{
var model = new Dictionary<string, object>(){
{"uint", (uint)123},
{"ushort", (ushort)234},
{"ulong", (ulong)18446744073709551615} // max ulong
};

Assert.Equal("123;234;18446744073709551615", Parser.Parse("{{uint}};{{ushort}};{{ulong}}")(model));
}

[Fact]
public void TemplateRendersWithComplextEachPath()
Expand Down
8 changes: 7 additions & 1 deletion Mustachio/ContextObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public bool Exists()
typeof(byte),
typeof(sbyte),
typeof(decimal),
typeof(uint),
typeof(ushort),
typeof(ulong),
typeof(int?),
typeof(bool?),
typeof(double?),
Expand All @@ -109,7 +112,10 @@ public bool Exists()
typeof(long?),
typeof(byte?),
typeof(sbyte?),
typeof(decimal?)
typeof(decimal?),
typeof(uint?),
typeof(ushort?),
typeof(ulong?)
};

public override string ToString()
Expand Down

0 comments on commit 3342716

Please sign in to comment.