Fix: Missing cultureinfo fails tests on non-US systems

This commit is contained in:
jchassaing 2023-05-22 09:06:40 +02:00
parent 08f4b4a372
commit 876808b1eb
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Tests.Functions.Type4
{
using System;
using System.Globalization;
using UglyToad.PdfPig.Functions.Type4;
using Xunit;
@ -60,7 +61,7 @@
/// <returns>this instance</returns>
public Type4Tester PopReal(double expected, double delta)
{
double value = Convert.ToDouble(context.Stack.Pop());
double value = Convert.ToDouble(context.Stack.Pop(), CultureInfo.InvariantCulture);
DoubleComparer doubleComparer = new DoubleComparer(delta);
Assert.True(doubleComparer.Equals(expected, value));//expected, value, delta);
return this;
@ -98,7 +99,7 @@
{
object value = context.PopNumber();
DoubleComparer doubleComparer = new DoubleComparer(delta);
Assert.True(doubleComparer.Equals(expected, Convert.ToDouble(value)));
Assert.True(doubleComparer.Equals(expected, Convert.ToDouble(value, CultureInfo.InvariantCulture)));
return this;
}

View File

@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Functions.Type4
{
using System.Collections.Generic;
using System.Globalization;
/// <summary>
/// Basic parser for Type 4 functions which is used to build up instruction sequences.
@ -62,13 +63,13 @@
}
else
{
if (int.TryParse(token, out int tokenInt))
if (int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out int tokenInt))
{
GetCurrentSequence().AddInteger(tokenInt);
return;
}
if (double.TryParse(token, out double tokenFloat))
if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out double tokenFloat))
{
GetCurrentSequence().AddReal(tokenFloat);
return;