fix: Fixes Point3D TryParse (#1298)
This commit is contained in:
parent
8e80c7f9c5
commit
f314c63175
2 changed files with 14 additions and 1 deletions
|
|
@ -5,6 +5,15 @@ namespace Server.Tests;
|
|||
|
||||
public class Point3DTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("(709, 2236, -2)", 709, 2236, -2)]
|
||||
public void TestPoint3DRegressions(string text, int x, int y, int z)
|
||||
{
|
||||
var successful = Point3D.TryParse(text, null, out var p);
|
||||
Assert.True(successful);
|
||||
Assert.Equal(new Point3D(x, y, z), p);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPoint3DToString()
|
||||
{
|
||||
|
|
@ -124,5 +133,9 @@ public class Point3DTests
|
|||
Assert.False(Point3D.TryParse("(,23,)", null, out p));
|
||||
Assert.Equal(default, p);
|
||||
Assert.Throws<FormatException>(() => Point3D.Parse("(,23,)", null));
|
||||
|
||||
Assert.False(Point3D.TryParse("(23,,-1)", null, out p));
|
||||
Assert.Equal(default, p);
|
||||
Assert.Throws<FormatException>(() => Point3D.Parse("(23,,-1)", null));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ public struct Point3D
|
|||
var offset = firstComma + 1;
|
||||
|
||||
var secondComma = s[offset..].IndexOfOrdinal(',');
|
||||
if (secondComma == -1 || offset == secondComma)
|
||||
if (secondComma == -1)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue