Skip to content

Commit af749be

Browse files
committed
test: GetDoubleValue as string
1 parent 77ea35d commit af749be

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/serialization/json/JsonParseNodeTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,27 @@ public void GetDoubleValue_CanReadNumber(string input, double? expected)
689689
}
690690
}
691691

692+
[Theory]
693+
[InlineData("13.37", 13.37D)]
694+
[InlineData("\"13.37\"", 13.37D)]
695+
[InlineData("null", null)]
696+
public void GetDoubleValue_CanReadNumber_AsString(string input, double? expected)
697+
{
698+
// Arrange
699+
using var jsonDocument = JsonDocument.Parse(input);
700+
var parseNode = new JsonParseNode(jsonDocument.RootElement);
701+
702+
// Act
703+
var actual = parseNode.GetDoubleValue();
704+
705+
// Assert
706+
Assert.Equal(expected.HasValue, actual.HasValue);
707+
if(expected.HasValue && actual.HasValue)
708+
{
709+
Assert.Equal(expected.Value, actual.Value);
710+
}
711+
}
712+
692713
[Theory]
693714
[InlineData("13.37", 13.37)]
694715
[InlineData("\"13.37\"", null)]

0 commit comments

Comments
 (0)