File tree 2 files changed +27
-1
lines changed
Elasticsearch.Net/Utf8Json/Internal/DoubleConversion
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 23
23
#endregion
24
24
25
25
using System ;
26
+ using System . Globalization ;
26
27
using System . Text ;
27
28
28
29
namespace Elasticsearch . Net . Utf8Json . Internal . DoubleConversion
@@ -636,7 +637,7 @@ static double StringToIeee(
636
637
input ++ ;
637
638
}
638
639
var laststr = Encoding . UTF8 . GetString ( fallbackbuffer , 0 , fallbackI ) ;
639
- return double . Parse ( laststr ) ;
640
+ return double . Parse ( laststr , CultureInfo . InvariantCulture ) ;
640
641
}
641
642
642
643
processed_characters_count = ( current - input ) ;
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using Elastic . Xunit . XunitPlumbing ;
3
+ using FluentAssertions ;
4
+ using Nest ;
5
+ using Tests . Core . Extensions ;
6
+ using Tests . Core . Serialization ;
7
+
8
+ namespace Tests . Reproduce
9
+ {
10
+ public class GithubIssue4057
11
+ {
12
+ [ U ]
13
+ [ UseCulture ( "sv-SE" ) ]
14
+ public void DoubleAffectedByPrecisionProblemDeserializesCorrectlyIndependentOfCurrentCulture ( )
15
+ {
16
+ var expected = 16.27749494276941D ;
17
+
18
+ var tester = SerializationTester . Default ;
19
+ var actual = tester . Deserializes < double > ( "16.27749494276941" ) ;
20
+
21
+ actual . Result . Should ( ) . NotBe ( expected ) ; // we are expecting precision problem;
22
+ Math . Round ( actual . Result , 13 ) . Should ( ) . Be ( Math . Round ( expected , 13 ) ) ;
23
+ }
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments