Skip to content
Next Next commit
include ParseRealLiteral tests
  • Loading branch information
RenanCarlosPereira authored Jun 25, 2024
commit e8dd3511f9e13a12f05a3ed88882c56980843bf1
28 changes: 27 additions & 1 deletion test/System.Linq.Dynamic.Core.Tests/Parser/NumberParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FluentAssertions;
using FluentAssertions;
using System.Collections.Generic;
using System.Globalization;
using System.Linq.Dynamic.Core.Parser;
Expand Down Expand Up @@ -152,5 +152,31 @@ public void NumberParser_ParseIntegerLiteral(string text, double expected)
// Assert
result.Value.Should().Be(expected);
}

[Theory]
[InlineData("42", 'm', 42)]
[InlineData("-42", 'm', -42)]
[InlineData("42m", 'm', 42)]
[InlineData("-42m", 'm', -42)]

[InlineData("42", 'd', 42)]
[InlineData("-42", 'd', -42)]
[InlineData("42d", 'd', 42)]
[InlineData("-42d", 'd', -42)]

[InlineData("42", 'f', 42)]
[InlineData("-42", 'f', -42)]
[InlineData("42f", 'f', 42)]
[InlineData("-42f", 'f', -42)]
public void NumberParser_ParseRealLiteral(string text, char qualifier, double expected)
{
// Arrange

// Act
var result = new NumberParser(_parsingConfig).ParseRealLiteral(text, qualifier, true) as ConstantExpression;

// Assert
result!.Value.Should().Be(expected);
}
}
}