Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<IKVMPackageVersion>8.7.5</IKVMPackageVersion>
<IKVMMavenSdkPackageVersion>1.6.7</IKVMMavenSdkPackageVersion>
<!-- J2N will break binary compatibility in 3.0.0 to fix the APIs of collection types -->
<J2NPackageVersion>[2.2.0-alpha-0021, 3.0.0)</J2NPackageVersion>
<J2NPackageVersion>[2.2.0-alpha-0026, 3.0.0)</J2NPackageVersion>
<LiquidTestReportsMarkdownPackageVersion>1.0.9</LiquidTestReportsMarkdownPackageVersion>
<LuceneNetCodeAnalysisDevPackageVersion>1.0.0-alpha.6</LuceneNetCodeAnalysisDevPackageVersion>
<MicrosoftAspNetCoreHttpAbstractionsPackageVersion>2.3.0</MicrosoftAspNetCoreHttpAbstractionsPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using J2N.Globalization;
using J2N.Numerics;
using Lucene.Net.Analysis;
using Lucene.Net.Attributes;
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Lucene.Net.Index.Extensions;
Expand Down Expand Up @@ -251,10 +253,10 @@ public override void SetUp()
)), LOCALE))
;

randomNumberMap[NumericType.INT64.ToString()] = (J2N.Numerics.Int64)randomLong;
randomNumberMap[NumericType.INT32.ToString()] = (J2N.Numerics.Int32)randomInt;
randomNumberMap[NumericType.SINGLE.ToString()] = (J2N.Numerics.Single)randomFloat;
randomNumberMap[NumericType.DOUBLE.ToString()] = (J2N.Numerics.Double)randomDouble;
randomNumberMap[nameof(NumericType.INT64)] = (J2N.Numerics.Int64)randomLong;
randomNumberMap[nameof(NumericType.INT32)] = (J2N.Numerics.Int32)randomInt;
randomNumberMap[nameof(NumericType.SINGLE)] = (J2N.Numerics.Single)randomFloat;
randomNumberMap[nameof(NumericType.DOUBLE)] = (J2N.Numerics.Double)randomDouble;
randomNumberMap[DATE_FIELD_NAME] = (J2N.Numerics.Int64)randomDate;

RANDOM_NUMBER_MAP = JCG.Extensions.DictionaryExtensions.AsReadOnly(randomNumberMap);
Expand Down Expand Up @@ -510,6 +512,41 @@ public void TestSimpleNumericQuery()
AssertSimpleQuery(NumberType.NEGATIVE, 1);
}

/// <summary>
/// Tests the fix for Lucene.NET GitHub issue #846.
/// Numeric values were failing for cultures that use a Unicode minus sign
/// (U+2212) rather than a hyphen-minus (U+002D) in exponential notation.
/// This was due to a bug in J2N (#128) that has since been fixed.
/// </summary>
/// <remarks>
/// https://github.com/NightOwl888/J2N/issues/128
/// </remarks>
[Test]
[LuceneNetSpecific]
public void TestInclusiveNumericRange_UnicodeMinus()
{
// Use a culture that uses a Unicode minus sign rather than a hyphen-minus
// in exponential notation.
LOCALE = new CultureInfo("sv-FI");
using (var cultureContext = new CultureContext(LOCALE))
{
NUMBER_FORMAT = new MockNumberFormat(LOCALE);

var randomNumberMap = new JCG.Dictionary<string, Number>(RANDOM_NUMBER_MAP!)
{
[nameof(NumericType.DOUBLE)] = J2N.Numerics.Double.GetInstance(1.0E-20),
[nameof(NumericType.SINGLE)] = J2N.Numerics.Single.GetInstance(1.0E-20f)
};

RANDOM_NUMBER_MAP = JCG.Extensions.DictionaryExtensions.AsReadOnly(randomNumberMap);

qp!.NumericConfigMap[nameof(NumericType.DOUBLE)] = new NumericConfig(PRECISION_STEP, NUMBER_FORMAT, NumericType.DOUBLE);
qp.NumericConfigMap[nameof(NumericType.SINGLE)] = new NumericConfig(PRECISION_STEP, NUMBER_FORMAT, NumericType.SINGLE);

AssertRangeQuery(NumberType.ZERO, NumberType.POSITIVE, true, true, 1);
}
}

public void AssertRangeQuery(NumberType? lowerType, NumberType? upperType,
bool lowerInclusive, bool upperInclusive, int expectedDocCount)
{
Expand Down