Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 4a2407e

Browse files
committed
fix single digits test
1 parent ed4a236 commit 4a2407e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ServiceStack.Text/DynamicNumber.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,12 @@ public static bool TryParse(string strValue, out object result)
674674
if (strValue.Length == 1)
675675
{
676676
int singleDigit = strValue[0];
677-
if (singleDigit >= 48 && singleDigit <= 57) // 0 - 9
677+
if (singleDigit >= '0' && singleDigit <= '9')
678678
{
679679
result = singleDigit - 48; // 0
680680
return true;
681681
}
682+
return false;
682683
}
683684

684685
var hasDecimal = strValue.IndexOf('.') >= 0;

tests/ServiceStack.Text.Tests/DynamicNumberTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public void Can_text_for_numbers()
208208
{
209209
object x = null;
210210
Assert.That(DynamicNumber.TryParse("(", out x), Is.False);
211+
Assert.That(DynamicNumber.TryParse("-", out x), Is.False);
211212
}
212213

213214

0 commit comments

Comments
 (0)