提交 96b95ebc 编写于 作者: N Neal Gafter

Merge pull request #7887 from gafter/fix7883a

Remove locale-dependence in RealParserTests
......@@ -377,13 +377,18 @@ static void TestRoundTripDouble(ulong bits)
{
double d = BitConverter.Int64BitsToDouble((long)bits);
if (double.IsInfinity(d) || double.IsNaN(d)) return;
string s = $"{d:G17}";
string s = InvariantToString(d);
CheckOneDouble(s, bits);
}
static string InvariantToString(object o)
{
return string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:G17}", o);
}
static void TestRoundTripDouble(double d)
{
string s = $"{d:G17}";
string s = InvariantToString(d);
CheckOneDouble(s, d);
}
......@@ -401,13 +406,13 @@ static void CheckOneDouble(string s, double expected)
#if DEBUG
throw new AssertFailureException($@"
Error for double input ""{s}""
expected {expected:G17}
actual {actual:G17}");
expected {InvariantToString(expected)}
actual {InvariantToString(actual)}");
#else
throw new Exception($@"
Error for double input ""{s}""
expected {expected:G17}
actual {actual:G17}");
expected {InvariantToString(expected)}
actual {InvariantToString(actual)}");
#endif
}
}
......@@ -559,13 +564,13 @@ static void TestRoundTripFloat(uint bits)
{
float d = Int32BitsToFloat(bits);
if (float.IsInfinity(d) || float.IsNaN(d)) return;
string s = $"{d:G17}";
string s = InvariantToString(d);
CheckOneFloat(s, bits);
}
static void TestRoundTripFloat(float d)
{
string s = $"{d:G17}";
string s = InvariantToString(d);
if (s != "NaN" && s != "Infinity") CheckOneFloat(s, d);
}
......@@ -582,12 +587,12 @@ static void CheckOneFloat(string s, float expected)
{
#if DEBUG
throw new AssertFailureException($@"Error for float input ""{s}""
expected {expected:G17}
actual {actual:G17}");
expected {InvariantToString(expected)}
actual {InvariantToString(actual)}");
#else
throw new Exception($@"Error for float input ""{s}""
expected {expected:G17}
actual {actual:G17}");
expected {InvariantToString(expected)}
actual {InvariantToString(actual)}");
#endif
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册