Class PowerFormatterTest

java.lang.Object
com.irurueta.units.PowerFormatterTest

class PowerFormatterTest extends Object
Tests for PowerFormatter.
  • Field Details

    • SPAIN

      private static final Locale SPAIN
      Spanish locale, which uses comma as decimal separator.
    • VALUE

      private static final double VALUE
      Value used in formatting tests.
      See Also:
  • Constructor Details

    • PowerFormatterTest

      PowerFormatterTest()
  • Method Details

    • constructor_whenEmpty_usesDefaultLocale

      @Test void constructor_whenEmpty_usesDefaultLocale()
      Checks default constructor.
    • constructor_whenLocale_usesLocale

      @Test void constructor_whenLocale_usesLocale()
      Checks constructor with 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 copy constructor.
    • constructor_whenNullFormatter_throwsNullPointerException

      @Test void constructor_whenNullFormatter_throwsNullPointerException()
      Checks that a null formatter to copy is rejected.
    • clone_whenCalled_returnsEqualInstance

      @Test void clone_whenCalled_returnsEqualInstance() throws CloneNotSupportedException
      Checks cloning, before and after the internal number format is initialized.
      Throws:
      CloneNotSupportedException - never happens.
    • equals_whenDifferentLocales_returnsExpectedResult

      @Test void equals_whenDifferentLocales_returnsExpectedResult()
      Checks equals and hash code.
    • format_whenAnyUnit_returnsValueAndSymbol

      @Test void format_whenAnyUnit_returnsValueAndSymbol()
      Checks formatting of numbers, doubles, measurements and string buffers.
    • formatAndConvertMetric_whenDifferentMagnitudes_selectsAppropriateUnit

      @Test void formatAndConvertMetric_whenDifferentMagnitudes_selectsAppropriateUnit()
      Checks metric formatting picks a unit by magnitude.
    • formatAndConvertImperial_whenAnyUnit_usesHorsepower

      @Test void formatAndConvertImperial_whenAnyUnit_usesHorsepower()
      Checks imperial formatting always uses horsepower.
    • formatAndConvert_whenUnitSystemGiven_dispatchesToSystem

      @Test void formatAndConvert_whenUnitSystemGiven_dispatchesToSystem()
      Checks conversion with unit system in all overloads and defaults.
    • getUnitSystem_whenSourceProvided_returnsSystemOrNull

      @Test void getUnitSystem_whenSourceProvided_returnsSystemOrNull()
      Checks unit system detection from a string.
    • parse_whenValidSource_returnsPower

      @Test void parse_whenValidSource_returnsPower() throws ParseException, UnknownUnitException
      Checks parsing of every unit.
      Throws:
      ParseException - if parsing fails.
      UnknownUnitException - if a unit is not recognized.
    • parse_whenUnknownUnit_throwsUnknownUnitException

      @Test void parse_whenUnknownUnit_throwsUnknownUnitException()
      Checks that an unknown unit is rejected.
    • parse_whenNoNumber_throwsParseException

      @Test void parse_whenNoNumber_throwsParseException()
      Checks that a source without a number is rejected.
    • findUnit_whenSourceProvided_returnsUnitOrNull

      @Test void findUnit_whenSourceProvided_returnsUnitOrNull()
      Checks unit detection in strings.
    • findUnit_whenUnsupportedPrefix_returnsNullAndParseFails

      @Test void findUnit_whenUnsupportedPrefix_returnsNullAndParseFails()
      Checks that unsupported prefixed units are rejected instead of being parsed as a supported unit.
    • getUnitSymbol_whenAnyUnit_returnsSymbol

      @Test void getUnitSymbol_whenAnyUnit_returnsSymbol()
      Checks unit symbols.