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
13 changes: 9 additions & 4 deletions CosmosDBShell.Tests/Parser/ShellObjectConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,15 @@ public void ShellJson_StringToNumber(string raw, int expected)
Assert.Equal(expected, Json(raw).ConvertShellObject(DataType.Number));
}

[Fact]
public void ShellJson_StringToDecimal()
{
Assert.Equal(15d, Assert.IsType<double>(Json("\"15\"").ConvertShellObject(DataType.Decimal)));
[Theory]
[InlineData("\"15\"", 15d)]
[InlineData("\"1.5\"", 1.5d)]
[InlineData("\"1e100\"", 1e100d)]
[InlineData("1e100", 1e100d)]
[InlineData("3.0", 3d)]
public void ShellJson_ToDecimal_ReturnsDouble(string raw, double expected)
{
Assert.Equal(expected, Assert.IsType<double>(Json(raw).ConvertShellObject(DataType.Decimal)));
}

[Fact]
Expand Down
8 changes: 8 additions & 0 deletions CosmosDBShell.Tests/Parser/StatementExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public static System.Collections.Generic.IEnumerable<object[]> ValueOriginCases(
("3.5", "+", "2", "Decimal", "5.5"),
("3", "/", "2", "Number", "1"),
("3.0", "/", "2", "Decimal", "1.5"),
("\"2\"", "*", "1.5", "Decimal", "3"),
("1.5", "*", "\"2\"", "Decimal", "3"),
("\"2\"", "-", "1.5", "Decimal", "0.5"),
("\"3.5\"", "/", "2.0", "Decimal", "1.75"),
("5.0", "%", "\"2\"", "Decimal", "1"),
("\"2\"", "**", "3.0", "Decimal", "8"),
("\"2\"", "<", "2.5", "Boolean", "true"),
("2.5", ">=", "\"2\"", "Boolean", "true"),
("3.0", "-", "\"2.5\"", "Decimal", "0.5"),
("\"2.5\"", "-", "3.0", "Decimal", "-0.5"),
("3.0", "*", "\"2.5\"", "Decimal", "7.5"),
Expand Down
Loading