Package com.irurueta.units
Class PowerFormatterTest
java.lang.Object
com.irurueta.units.PowerFormatterTest
Tests for
PowerFormatter.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidChecks cloning, before and after the internal number format is initialized.(package private) voidChecks copy constructor.(package private) voidChecks default constructor.(package private) voidChecks constructor with locale.(package private) voidChecks that a null formatter to copy is rejected.(package private) voidChecks that a null locale is rejected.(package private) voidChecks equals and hash code.(package private) voidChecks unit detection in strings.(package private) voidChecks that unsupported prefixed units are rejected instead of being parsed as a supported unit.(package private) voidChecks formatting of numbers, doubles, measurements and string buffers.(package private) voidChecks conversion with unit system in all overloads and defaults.(package private) voidChecks imperial formatting always uses horsepower.(package private) voidChecks metric formatting picks a unit by magnitude.(package private) voidChecks unit symbols.(package private) voidChecks unit system detection from a string.(package private) voidChecks that a source without a number is rejected.(package private) voidChecks that an unknown unit is rejected.(package private) voidChecks parsing of every unit.
-
Field Details
-
SPAIN
Spanish locale, which uses comma as decimal separator. -
VALUE
private static final double VALUEValue 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
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
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.
-