Package org.djutils.base
Class NumberParserTest
java.lang.Object
org.djutils.base.NumberParserTest
NumberParserTest tests the NumberParser.
 
Copyright (c) 2023-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
 - Alexander Verbraeck
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidHelper method to print the internal formatting of an Arab number in unicode.(package private) NumberParsermakeNumberParserChaining(boolean lenient, boolean trailing, Locale locale) Make a NumberParser through chaining with all possible combinations.voidTest the NumberParser constructors.voidtestDouble(String text, double expectedAnswer, String expectedTrailing, boolean strict, Locale locale) Test a parsing testcase for Double values.voidtestDoubleFail(String text, boolean strict, boolean trailing, Locale locale) Test whether parsing of double fails as expected.voidtestFloat(String text, float expectedAnswer, String expectedTrailing, boolean strict, Locale locale) Test a parsing testcase for Float values.voidtestFloatFail(String text, boolean strict, boolean trailing, Locale locale) Test whether parsing of float fails as expected.voidtestNPE()Test the NumberParser for NullPointer and empty string exceptions.voidTest with a few settings for the Arabic locale.voidTest with a few settings for the Arabic locale.voidTest with a few settings for the Arabic locale.voidTest with a few settings for the FR locale.voidTest with a few settings for the FR locale.voidTest with a few settings for the FR locale.voidTest with a few settings for the NL locale.voidTest with a few settings for the US locale. 
- 
Constructor Details
- 
NumberParserTest
public NumberParserTest() 
 - 
 - 
Method Details
- 
testNPE
@Test public void testNPE()Test the NumberParser for NullPointer and empty string exceptions. - 
testConstructors
@Test public void testConstructors()Test the NumberParser constructors. - 
testNumberParserFloatUS
@Test public void testNumberParserFloatUS()Test with a few settings for the US locale. - 
testNumberParserFloatNL
@Test public void testNumberParserFloatNL()Test with a few settings for the NL locale. - 
testNumberParserFloatFRjdk17
public void testNumberParserFloatFRjdk17()Test with a few settings for the FR locale. Note that the Locale for France in jdk17 is different from jdk11. See https://stackoverflow.com/questions/70865403/why-numberformat-working-different-for-openjdk11-and-openjdk17 and https://bugs.openjdk.org/browse/JDK-8225245 for more information. The jdk17 standard can be downloaded from https://unicode.org/Public/cldr/35.1/. The jdk11 standard can be downloaded from https://unicode.org/Public/cldr/33/. - 
testNumberParserFloatFRjdk11
public void testNumberParserFloatFRjdk11()Test with a few settings for the FR locale. Note that the Locale for France in jdk17 is different from jdk11. See https://stackoverflow.com/questions/70865403/why-numberformat-working-different-for-openjdk11-and-openjdk17 and https://bugs.openjdk.org/browse/JDK-8225245 for more information. The jdk17 standard can be downloaded from https://unicode.org/Public/cldr/35.1/. The jdk11 standard can be downloaded from https://unicode.org/Public/cldr/33/. - 
testNumberParserFloatFR
@Test public void testNumberParserFloatFR()Test with a few settings for the FR locale. Note that the Locale for France in jdk17 is different from jdk11. See https://stackoverflow.com/questions/70865403/why-numberformat-working-different-for-openjdk11-and-openjdk17 for more information. The jdk17 standard can be downloaded from https://unicode.org/Public/cldr/35.1/. The jdk11 standard can be downloaded from https://unicode.org/Public/cldr/33/. - 
testNumberParserFloatArabicJdk17
public void testNumberParserFloatArabicJdk17()Test with a few settings for the Arabic locale. Note that Arabic is written right-to-left, but the numbers in a Java String are still formatted left-to-right. Note that the Locale for Arabic in jdk17 is different from jdk11. See https://stackoverflow.com/questions/72738425/numberformating-issue-with-negative-numbers-in-rtl-locale-like-arabic for more information. The jdk17 standard can be downloaded from https://unicode.org/Public/cldr/35.1/. The jdk11 standard can be downloaded from https://unicode.org/Public/cldr/33/. - 
testNumberParserFloatArabicJdk11
public void testNumberParserFloatArabicJdk11()Test with a few settings for the Arabic locale. Note that Arabic is written right-to-left, but the numbers in a Java String are still formatted left-to-right. Note that the Locale for Arabic in jdk17 is different from jdk11. See https://stackoverflow.com/questions/72738425/numberformating-issue-with-negative-numbers-in-rtl-locale-like-arabic for more information. The jdk17 standard can be downloaded from https://unicode.org/Public/cldr/35.1/. The jdk11 standard can be downloaded from https://unicode.org/Public/cldr/33/. - 
testNumberParserFloatArabic
@Test public void testNumberParserFloatArabic()Test with a few settings for the Arabic locale. Note that Arabic is written right-to-left, but the numbers in a Java String are still formatted left-to-right. Note that the Locale for Arabic in jdk17 is different from jdk11. See https://stackoverflow.com/questions/72738425/numberformating-issue-with-negative-numbers-in-rtl-locale-like-arabic for more information. The jdk17 standard can be downloaded from https://unicode.org/Public/cldr/35.1/. The jdk11 standard can be downloaded from https://unicode.org/Public/cldr/33/. - 
arabicStringToHex
public void arabicStringToHex()Helper method to print the internal formatting of an Arab number in unicode. - 
testDouble
public void testDouble(String text, double expectedAnswer, String expectedTrailing, boolean strict, Locale locale) Test a parsing testcase for Double values.- Parameters:
 text- the text to parseexpectedAnswer- the expected numerical answerexpectedTrailing- String the expected trailing infostrict- whether the text String is strict or notlocale- the locale to test for
 - 
testFloat
public void testFloat(String text, float expectedAnswer, String expectedTrailing, boolean strict, Locale locale) Test a parsing testcase for Float values.- Parameters:
 text- the text to parseexpectedAnswer- the expected numerical answerexpectedTrailing- String the expected trailing infostrict- whether the text String is strict or notlocale- the locale to test for
 - 
testDoubleFail
Test whether parsing of double fails as expected.- Parameters:
 text- the text to parsestrict- whether to apply strict parsing or nottrailing- whether to allow trailing or notlocale- the locale to use
 - 
testFloatFail
Test whether parsing of float fails as expected.- Parameters:
 text- the text to parsestrict- whether to apply strict parsing or nottrailing- whether to allow trailing or notlocale- the locale to use
 - 
makeNumberParserChaining
Make a NumberParser through chaining with all possible combinations.- Parameters:
 lenient- lenient or stricttrailing- trailing info on or offlocale- when null, no locale is set (using Locale.getDefault())- Returns:
 - NumberParser made through chaining
 
 
 -