Package com.irurueta.units
Class EnergyFormatterTest
java.lang.Object
com.irurueta.units.EnergyFormatterTest
Unit tests for
EnergyFormatter.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidChecks cloning, before and after the internal number format is initialized.(package private) voidChecks the empty, locale and copy constructors, and that a null locale or formatter is rejected.(package private) voidChecks equality semantics.(package private) voidChecks unit detection on text.(package private) voidChecks that symbols only match as whole tokens, so that unsupported prefixed units (such as gigajoules or millijoules) are rejected rather than misparsed as joules, while a symbol followed by trailing text still matches.(package private) voidChecks formatting of double values.(package private) voidChecks formatting of double values into a buffer.(package private) voidChecks formatting of energies.(package private) voidChecks formatting of energies into a buffer.(package private) voidChecks formatting ofNumbervalues.(package private) voidChecks formatting ofNumbervalues into a buffer.(package private) voidChecks that formatting and converting a double uses the locale unit system.(package private) voidChecks formatting and conversion of double values with an explicit unit system.(package private) voidChecks that formatting and converting an energy uses the locale unit system.(package private) voidChecks formatting and conversion of energies with an explicit unit system.(package private) voidChecks that formatting and converting aNumberuses the locale unit system.(package private) voidChecks formatting and conversion ofNumbervalues with an explicit unit system.(package private) voidChecks that imperial formatting always uses BTU.(package private) voidChecks that metric formatting picks the most suitable metric unit.(package private) voidChecks available locales.(package private) voidChecks unit symbols.(package private) voidChecks that the unit system depends on the locale.(package private) voidChecks unit system detection on text.(package private) voidChecks hash code semantics.(package private) voidChecks imperial unit detection on text.(package private) voidChecks metric unit detection on text.(package private) voidChecks measurement validation.(package private) voidChecks that every known symbol is a valid unit, with or without trailing space.(package private) voidChecks parsing of valid text, and that unknown units and missing values are rejected.(package private) voidChecks getter and setter of grouping flag.(package private) voidChecks getter and setter of maximum fraction digits.(package private) voidChecks getter and setter of maximum integer digits.(package private) voidChecks getter and setter of minimum fraction digits.(package private) voidChecks getter and setter of minimum integer digits.(package private) voidChecks getter and setter of parse integer only flag.(package private) voidChecks getter and setter of rounding mode.(package private) voidChecks getter and setter of the value and unit format pattern, and that a null pattern is rejected.
-
Constructor Details
-
EnergyFormatterTest
EnergyFormatterTest()
-
-
Method Details
-
constructor_whenEmptyLocaleOrCopy_initializesExpectedState
@Test void constructor_whenEmptyLocaleOrCopy_initializesExpectedState()Checks the empty, locale and copy constructors, and that a null locale or formatter 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 ofNumbervalues. -
format_whenNumberAndBuffer_appendsValueAndSymbol
@Test void format_whenNumberAndBuffer_appendsValueAndSymbol()Checks formatting ofNumbervalues 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_whenEnergy_returnsValueAndSymbol
@Test void format_whenEnergy_returnsValueAndSymbol()Checks formatting of energies. -
format_whenEnergyAndBuffer_appendsValueAndSymbol
@Test void format_whenEnergyAndBuffer_appendsValueAndSymbol()Checks formatting of energies into a buffer. -
formatAndConvert_whenNumberAndNoUnitSystem_usesLocaleSystem
@Test void formatAndConvert_whenNumberAndNoUnitSystem_usesLocaleSystem()Checks that formatting and converting aNumberuses the locale unit system. -
formatAndConvert_whenDoubleAndNoUnitSystem_usesLocaleSystem
@Test void formatAndConvert_whenDoubleAndNoUnitSystem_usesLocaleSystem()Checks that formatting and converting a double uses the locale unit system. -
formatAndConvert_whenEnergyAndNoUnitSystem_usesLocaleSystem
@Test void formatAndConvert_whenEnergyAndNoUnitSystem_usesLocaleSystem()Checks that formatting and converting an energy uses the locale unit system. -
formatAndConvert_whenNumberAndUnitSystem_usesGivenSystem
@Test void formatAndConvert_whenNumberAndUnitSystem_usesGivenSystem()Checks formatting and conversion ofNumbervalues with an explicit unit system. -
formatAndConvert_whenDoubleAndUnitSystem_usesGivenSystem
@Test void formatAndConvert_whenDoubleAndUnitSystem_usesGivenSystem()Checks formatting and conversion of double values with an explicit unit system. -
formatAndConvert_whenEnergyAndUnitSystem_usesGivenSystem
@Test void formatAndConvert_whenEnergyAndUnitSystem_usesGivenSystem()Checks formatting and conversion of energies with an explicit unit system. -
formatAndConvertMetric_whenDifferentMagnitudes_picksBestMetricUnit
@Test void formatAndConvertMetric_whenDifferentMagnitudes_picksBestMetricUnit()Checks that metric formatting picks the most suitable metric unit. -
formatAndConvertImperial_whenAnyUnit_returnsBtu
@Test void formatAndConvertImperial_whenAnyUnit_returnsBtu()Checks that imperial formatting always uses BTU. -
getAvailableLocales_whenCalled_returnsNumberFormatLocales
@Test void getAvailableLocales_whenCalled_returnsNumberFormatLocales()Checks available locales. -
setMaximumFractionDigits_whenValid_updatesValue
@Test void setMaximumFractionDigits_whenValid_updatesValue()Checks getter and setter of maximum fraction digits. -
setMaximumIntegerDigits_whenValid_updatesValue
@Test void setMaximumIntegerDigits_whenValid_updatesValue()Checks getter and setter of maximum integer digits. -
setMinimumFractionDigits_whenValid_updatesValue
@Test void setMinimumFractionDigits_whenValid_updatesValue()Checks getter and setter of minimum fraction digits. -
setMinimumIntegerDigits_whenValid_updatesValue
@Test void setMinimumIntegerDigits_whenValid_updatesValue()Checks getter and setter of minimum integer digits. -
setRoundingMode_whenValid_updatesValue
@Test void setRoundingMode_whenValid_updatesValue()Checks getter and setter of rounding mode. -
setGroupingUsed_whenToggled_updatesValue
@Test void setGroupingUsed_whenToggled_updatesValue()Checks getter and setter of grouping flag. -
setParseIntegerOnly_whenToggled_updatesValue
@Test void setParseIntegerOnly_whenToggled_updatesValue()Checks getter and setter of parse integer only flag. -
setValueAndUnitFormatPattern_whenValidOrNull_updatesPatternOrThrows
@Test void setValueAndUnitFormatPattern_whenValidOrNull_updatesPatternOrThrows()Checks getter and setter of the value and unit format pattern, and that a null pattern is rejected. -
getUnitSystem_whenLocale_returnsLocaleUnitSystem
@Test void getUnitSystem_whenLocale_returnsLocaleUnitSystem()Checks that the unit system depends on the locale. -
isValidUnit_whenKnownSymbol_returnsTrue
@Test void isValidUnit_whenKnownSymbol_returnsTrue()Checks that every known symbol is a valid unit, with or without trailing space. -
isValidMeasurement_whenSource_returnsExpectedResult
@Test void isValidMeasurement_whenSource_returnsExpectedResult()Checks measurement validation. -
isMetricUnit_whenSource_returnsExpectedResult
@Test void isMetricUnit_whenSource_returnsExpectedResult()Checks metric unit detection on text. -
isImperialUnit_whenSource_returnsExpectedResult
@Test void isImperialUnit_whenSource_returnsExpectedResult()Checks imperial unit detection on text. -
getUnitSystem_whenSource_returnsDetectedSystem
@Test void getUnitSystem_whenSource_returnsDetectedSystem()Checks unit system detection on text. -
parse_whenSource_returnsValueAndUnitOrThrows
@Test void parse_whenSource_returnsValueAndUnitOrThrows() throws ParseException, UnknownUnitExceptionChecks parsing of valid text, and that unknown units and missing values are rejected.- Throws:
ParseException- never happens.UnknownUnitException- never happens.
-
findUnit_whenSource_returnsDetectedUnit
@Test void findUnit_whenSource_returnsDetectedUnit()Checks unit detection on text. -
findUnit_whenUnsupportedPrefixedUnit_returnsNullAndParseThrowsUnknownUnitException
@Test void findUnit_whenUnsupportedPrefixedUnit_returnsNullAndParseThrowsUnknownUnitException()Checks that symbols only match as whole tokens, so that unsupported prefixed units (such as gigajoules or millijoules) are rejected rather than misparsed as joules, while a symbol followed by trailing text still matches. -
getUnitSymbol_whenUnit_returnsSymbol
@Test void getUnitSymbol_whenUnit_returnsSymbol()Checks unit symbols.
-