Class EnergyFormatterTest

java.lang.Object
com.irurueta.units.EnergyFormatterTest

class EnergyFormatterTest extends Object
Unit tests for EnergyFormatter.
  • 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

      @Test void clone_whenCalled_returnsEqualDifferentInstance() throws CloneNotSupportedException
      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_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 a Number uses 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 of Number values 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, UnknownUnitException
      Checks 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.