Package org.djutils.base
Class NumberParserTest
java.lang.Object
org.djutils.base.NumberParserTest
NumberParserTest tests the NumberParser.
Copyright (c) 2023-2024 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
Modifier and TypeClassDescription(package private) static class
(package private) static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Helper method to print the internal formatting of an Arab number in unicode.(package private) NumberParser
makeNumberParserChaining
(boolean lenient, boolean trailing, Locale locale) Make a NumberParser through chaining with all possible combinations.void
Test the NumberParser constructors.void
testDouble
(String text, double expectedAnswer, String expectedTrailing, boolean strict, Locale locale) Test a parsing testcase for Double values.void
testDoubleFail
(String text, boolean strict, boolean trailing, Locale locale) Test whether parsing of double fails as expected.void
testFloat
(String text, float expectedAnswer, String expectedTrailing, boolean strict, Locale locale) Test a parsing testcase for Float values.void
testFloatFail
(String text, boolean strict, boolean trailing, Locale locale) Test whether parsing of float fails as expected.void
testNPE()
Test the NumberParser for NullPointer and empty string exceptions.void
Test with a few settings for the Arabic locale.void
Test with a few settings for the Arabic locale.void
Test with a few settings for the Arabic locale.void
Test with a few settings for the FR locale.void
Test with a few settings for the FR locale.void
Test with a few settings for the FR locale.void
Test with a few settings for the NL locale.void
Test 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
- String; the text to parseexpectedAnswer
- double; the expected numerical answerexpectedTrailing
- String the expected trailing infostrict
- boolean; whether the text String is strict or notlocale
- Locale; 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
- String; the text to parseexpectedAnswer
- float; the expected numerical answerexpectedTrailing
- String the expected trailing infostrict
- boolean; whether the text String is strict or notlocale
- Locale; the locale to test for
-
testDoubleFail
Test whether parsing of double fails as expected.- Parameters:
text
- String; the text to parsestrict
- boolean; whether to apply strict parsing or nottrailing
- boolean; whether to allow trailing or notlocale
- Locale; the locale to use
-
testFloatFail
Test whether parsing of float fails as expected.- Parameters:
text
- String; the text to parsestrict
- boolean; whether to apply strict parsing or nottrailing
- boolean; whether to allow trailing or notlocale
- Locale; the locale to use
-
makeNumberParserChaining
Make a NumberParser through chaining with all possible combinations.- Parameters:
lenient
- boolean; lenient or stricttrailing
- boolean; trailing info on or offlocale
- Locale; when null, no locale is set (using Locale.getDefault())- Returns:
- NumberParser made through chaining
-