Package com.irurueta.units
Class ForceFormatterTest
java.lang.Object
com.irurueta.units.ForceFormatterTest
Unit tests for
ForceFormatter.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intMaximum fraction digits used in conversion tests.private static final LocaleSpanish locale (metric, comma as decimal separator).private static final LocaleUS locale (imperial, dot as decimal separator).private static final doubleValue used when formatting. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidChecks cloning, before and after the internal number format is initialized.(package private) voidChecks that unit symbols are the expected ones.(package private) voidChecks the copy constructor.(package private) voidChecks the empty constructor uses defaults.(package private) voidChecks the constructor with locale uses that locale.(package private) voidChecks that a null formatter to copy is rejected.(package private) voidChecks that a null locale is rejected.(package private) voidChecks equality semantics.(package private) voidChecks unit detection, notably that kilonewton is not mistaken for newton.(package private) voidChecks that unsupported prefixed units are rejected instead of being parsed as a supported unit.(package private) voidChecks formatting of double values.(package private) voidChecks formatting of double values into a buffer.(package private) voidChecks formatting of force instances.(package private) voidChecks formatting of force instances into a buffer.(package private) voidChecks formatting of number values.(package private) voidChecks formatting of number values into a buffer.(package private) voidChecks formatAndConvert with double and unit system.(package private) voidChecks formatAndConvert with force and unit system.(package private) voidChecks formatAndConvert using the unit system of the locale.(package private) voidChecks formatAndConvert with number and unit system.(package private) voidChecks imperial conversion always yields pound-force.(package private) voidChecks metric conversion by magnitude.(package private) voidChecks available locales.(package private) voidChecks unit symbols.(package private) voidChecks the unit system of the formatter depends on its locale.(package private) voidChecks unit system detection from source.(package private) voidChecks hash code semantics.(package private) voidChecks imperial unit detection.(package private) voidChecks metric unit detection.(package private) voidChecks measurement validity detection.(package private) voidChecks unit validity detection.(package private) voidChecks that formatted values can be parsed back.(package private) voidChecks that parsing a source without a value fails.(package private) voidChecks that parsing a source with unknown unit fails.(package private) voidChecks parsing of every supported unit.(package private) voidChecks grouping accessors.(package private) voidChecks maximum fraction digits accessors.(package private) voidChecks maximum integer digits accessors.(package private) voidChecks minimum fraction digits accessors.(package private) voidChecks minimum integer digits accessors.(package private) voidChecks parse integer only accessors.(package private) voidChecks rounding mode accessors.(package private) voidChecks that a null pattern is rejected.(package private) voidChecks value and unit format pattern accessors.
-
Field Details
-
SPAIN
Spanish locale (metric, comma as decimal separator). -
US
US locale (imperial, dot as decimal separator). -
VALUE
private static final double VALUEValue used when formatting.- See Also:
-
FRACTION_DIGITS
private static final int FRACTION_DIGITSMaximum fraction digits used in conversion tests.- See Also:
-
-
Constructor Details
-
ForceFormatterTest
ForceFormatterTest()
-
-
Method Details
-
constants_whenRead_matchExpectedSymbols
@Test void constants_whenRead_matchExpectedSymbols()Checks that unit symbols are the expected ones. -
constructor_whenEmpty_usesDefaults
@Test void constructor_whenEmpty_usesDefaults()Checks the empty constructor uses defaults. -
constructor_whenLocale_usesLocale
@Test void constructor_whenLocale_usesLocale()Checks the constructor with locale uses that locale. -
constructor_whenNullLocale_throwsIllegalArgumentException
@Test void constructor_whenNullLocale_throwsIllegalArgumentException()Checks that a null locale is rejected. -
constructor_whenCopy_copiesLocale
@Test void constructor_whenCopy_copiesLocale()Checks the copy constructor. -
constructor_whenNullFormatter_throwsNullPointerException
@Test void constructor_whenNullFormatter_throwsNullPointerException()Checks that a null formatter to copy is rejected. -
clone_whenCalled_returnsEqualDifferentInstance
Checks cloning, before and after the internal number format is initialized.- Throws:
CloneNotSupportedException- never happens.
-
equals_whenDifferentLocales_comparesLocale
@Test void equals_whenDifferentLocales_comparesLocale()Checks equality semantics. -
hashCode_whenDifferentLocales_isConsistentWithEquals
@Test void hashCode_whenDifferentLocales_isConsistentWithEquals()Checks hash code semantics. -
format_whenNumber_returnsValueAndSymbol
@Test void format_whenNumber_returnsValueAndSymbol()Checks formatting of number values. -
format_whenNumberAndBuffer_appendsValueAndSymbol
@Test void format_whenNumberAndBuffer_appendsValueAndSymbol()Checks formatting of number values into a buffer. -
format_whenDouble_returnsValueAndSymbol
@Test void format_whenDouble_returnsValueAndSymbol()Checks formatting of double values. -
format_whenDoubleAndBuffer_appendsValueAndSymbol
@Test void format_whenDoubleAndBuffer_appendsValueAndSymbol()Checks formatting of double values into a buffer. -
format_whenForce_returnsValueAndSymbol
@Test void format_whenForce_returnsValueAndSymbol()Checks formatting of force instances. -
format_whenForceAndBuffer_appendsValueAndSymbol
@Test void format_whenForceAndBuffer_appendsValueAndSymbol()Checks formatting of force instances into a buffer. -
formatAndConvertMetric_whenDifferentMagnitudes_picksNewtonOrKilonewton
@Test void formatAndConvertMetric_whenDifferentMagnitudes_picksNewtonOrKilonewton()Checks metric conversion by magnitude. -
formatAndConvertImperial_whenAnyUnit_returnsPoundForce
@Test void formatAndConvertImperial_whenAnyUnit_returnsPoundForce()Checks imperial conversion always yields pound-force. -
formatAndConvert_whenNumberAndUnitSystem_usesGivenSystem
@Test void formatAndConvert_whenNumberAndUnitSystem_usesGivenSystem()Checks formatAndConvert with number and unit system. -
formatAndConvert_whenDoubleAndUnitSystem_usesGivenSystem
@Test void formatAndConvert_whenDoubleAndUnitSystem_usesGivenSystem()Checks formatAndConvert with double and unit system. -
formatAndConvert_whenForceAndUnitSystem_usesGivenSystem
@Test void formatAndConvert_whenForceAndUnitSystem_usesGivenSystem()Checks formatAndConvert with force and unit system. -
formatAndConvert_whenNoUnitSystem_usesLocaleSystem
@Test void formatAndConvert_whenNoUnitSystem_usesLocaleSystem()Checks formatAndConvert using the unit system of the locale. -
getAvailableLocales_whenCalled_returnsNumberFormatLocales
@Test void getAvailableLocales_whenCalled_returnsNumberFormatLocales()Checks available locales. -
setMaximumFractionDigits_whenValid_updatesValue
@Test void setMaximumFractionDigits_whenValid_updatesValue()Checks maximum fraction digits accessors. -
setMaximumIntegerDigits_whenValid_updatesValue
@Test void setMaximumIntegerDigits_whenValid_updatesValue()Checks maximum integer digits accessors. -
setMinimumFractionDigits_whenValid_updatesValue
@Test void setMinimumFractionDigits_whenValid_updatesValue()Checks minimum fraction digits accessors. -
setMinimumIntegerDigits_whenValid_updatesValue
@Test void setMinimumIntegerDigits_whenValid_updatesValue()Checks minimum integer digits accessors. -
setRoundingMode_whenValid_updatesValue
@Test void setRoundingMode_whenValid_updatesValue()Checks rounding mode accessors. -
setGroupingUsed_whenToggled_updatesValue
@Test void setGroupingUsed_whenToggled_updatesValue()Checks grouping accessors. -
setParseIntegerOnly_whenToggled_updatesValue
@Test void setParseIntegerOnly_whenToggled_updatesValue()Checks parse integer only accessors. -
setValueAndUnitFormatPattern_whenValid_updatesPattern
@Test void setValueAndUnitFormatPattern_whenValid_updatesPattern()Checks value and unit format pattern accessors. -
setValueAndUnitFormatPattern_whenNull_throwsIllegalArgumentException
@Test void setValueAndUnitFormatPattern_whenNull_throwsIllegalArgumentException()Checks that a null pattern is rejected. -
getUnitSystem_whenLocale_returnsLocaleUnitSystem
@Test void getUnitSystem_whenLocale_returnsLocaleUnitSystem()Checks the unit system of the formatter depends on its locale. -
isValidUnit_whenKnownSymbol_returnsTrue
@Test void isValidUnit_whenKnownSymbol_returnsTrue()Checks unit validity detection. -
isValidMeasurement_whenSource_returnsExpectedResult
@Test void isValidMeasurement_whenSource_returnsExpectedResult()Checks measurement validity detection. -
isMetricUnit_whenSource_returnsExpectedResult
@Test void isMetricUnit_whenSource_returnsExpectedResult()Checks metric unit detection. -
isImperialUnit_whenSource_returnsExpectedResult
@Test void isImperialUnit_whenSource_returnsExpectedResult()Checks imperial unit detection. -
getUnitSystem_whenSource_returnsDetectedSystem
@Test void getUnitSystem_whenSource_returnsDetectedSystem()Checks unit system detection from source. -
parse_whenValidSource_returnsValueAndUnit
Checks parsing of every supported unit.- Throws:
ParseException- never happens.UnknownUnitException- never happens.
-
parse_whenUnknownUnit_throwsUnknownUnitException
@Test void parse_whenUnknownUnit_throwsUnknownUnitException()Checks that parsing a source with unknown unit fails. -
parse_whenNoValue_throwsParseException
@Test void parse_whenNoValue_throwsParseException()Checks that parsing a source without a value fails. -
parse_whenFormattedValue_roundTrips
Checks that formatted values can be parsed back.- Throws:
ParseException- never happens.UnknownUnitException- never happens.
-
findUnit_whenSource_returnsDetectedUnit
@Test void findUnit_whenSource_returnsDetectedUnit()Checks unit detection, notably that kilonewton is not mistaken for newton. -
findUnit_whenUnsupportedPrefix_returnsNullAndParseFails
@Test void findUnit_whenUnsupportedPrefix_returnsNullAndParseFails()Checks that unsupported prefixed units are rejected instead of being parsed as a supported unit. -
getUnitSymbol_whenUnit_returnsSymbol
@Test void getUnitSymbol_whenUnit_returnsSymbol()Checks unit symbols.
-