Class ForceFormatterTest

java.lang.Object
com.irurueta.units.ForceFormatterTest

class ForceFormatterTest extends Object
Unit tests for ForceFormatter.
  • Field Details

    • SPAIN

      private static final Locale SPAIN
      Spanish locale (metric, comma as decimal separator).
    • US

      private static final Locale US
      US locale (imperial, dot as decimal separator).
    • VALUE

      private static final double VALUE
      Value used when formatting.
      See Also:
    • FRACTION_DIGITS

      private static final int FRACTION_DIGITS
      Maximum 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

      @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_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

      @Test void parse_whenValidSource_returnsValueAndUnit() throws ParseException, UnknownUnitException
      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

      @Test void parse_whenFormattedValue_roundTrips() throws ParseException, UnknownUnitException
      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.