Package com.irurueta.units
Class PressureFormatterTest
java.lang.Object
com.irurueta.units.PressureFormatterTest
Tests for
PressureFormatter.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intMaximum fraction digits used to get deterministic output.private static final LocaleSpanish locale (metric, decimal comma).private static final LocaleUS locale (imperial, decimal point).private static final doubleValue used when formatting without conversion. -
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 default constructor.(package private) voidChecks the copy constructor.(package private) voidChecks the constructor with locale.(package private) voidChecks that a null formatter is rejected by the copy constructor.(package private) voidChecks that a null locale is rejected.(package private) voidChecks equality 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 every unit through all format overloads.(package private) voidChecks conversion using the unit system of the formatter locale.(package private) voidChecks conversion with an explicit unit system, for every overload.(package private) voidChecks that imperial conversion always uses psi.(package private) voidChecks metric conversion thresholds.(package private) voidChecks unit symbols.(package private) voidChecks that the formatter locale determines its default unit system.(package private) voidChecks unit system detection from strings.(package private) voidChecks imperial unit detection in strings.(package private) voidChecks metric unit detection in strings.(package private) voidChecks measurement validity, metric and imperial detection.(package private) voidChecks that validity checks recognize every unit symbol.(package private) voidChecks parsing of every unit, including kPa not being mistaken for Pa.(package private) voidChecks that a string without a number fails parsing.(package private) voidChecks that an unknown unit fails parsing.
-
Field Details
-
VALUE
private static final double VALUEValue used when formatting without conversion.- See Also:
-
FRACTION_DIGITS
private static final int FRACTION_DIGITSMaximum fraction digits used to get deterministic output.- See Also:
-
SPAIN
Spanish locale (metric, decimal comma). -
US
US locale (imperial, decimal point).
-
-
Constructor Details
-
PressureFormatterTest
PressureFormatterTest()
-
-
Method Details
-
constructor_whenEmpty_usesDefaultLocale
@Test void constructor_whenEmpty_usesDefaultLocale()Checks the default constructor. -
constructor_whenLocale_usesLocale
@Test void constructor_whenLocale_usesLocale()Checks the constructor with locale. -
constructor_whenNullLocale_throwsIllegalArgumentException
@Test void constructor_whenNullLocale_throwsIllegalArgumentException()Checks that a null locale is rejected. -
constructor_whenFormatter_copiesLocale
@Test void constructor_whenFormatter_copiesLocale()Checks the copy constructor. -
constructor_whenNullFormatter_throwsNullPointerException
@Test void constructor_whenNullFormatter_throwsNullPointerException()Checks that a null formatter is rejected by the copy constructor. -
clone_whenCalled_returnsEqualButDifferentInstance
Checks cloning before and after the internal number format is initialized.- Throws:
CloneNotSupportedException
-
equals_whenSameOrDifferentLocale_returnsExpectedResult
@Test void equals_whenSameOrDifferentLocale_returnsExpectedResult()Checks equality and hash code. -
format_whenAnyOverload_returnsValueAndSymbol
@Test void format_whenAnyOverload_returnsValueAndSymbol()Checks formatting of every unit through all format overloads. -
formatAndConvertMetric_whenDifferentMagnitudes_picksPascalKilopascalOrBar
@Test void formatAndConvertMetric_whenDifferentMagnitudes_picksPascalKilopascalOrBar()Checks metric conversion thresholds. -
formatAndConvertImperial_whenAnyUnit_returnsPsi
@Test void formatAndConvertImperial_whenAnyUnit_returnsPsi()Checks that imperial conversion always uses psi. -
formatAndConvert_whenUnitSystem_usesThatSystem
@Test void formatAndConvert_whenUnitSystem_usesThatSystem()Checks conversion with an explicit unit system, for every overload. -
formatAndConvert_whenNoUnitSystem_usesLocaleSystem
@Test void formatAndConvert_whenNoUnitSystem_usesLocaleSystem()Checks conversion using the unit system of the formatter locale. -
isValidUnit_whenKnownSymbol_returnsTrue
@Test void isValidUnit_whenKnownSymbol_returnsTrue()Checks that validity checks recognize every unit symbol. -
isValidMeasurement_whenKnownOrUnknownUnit_returnsExpectedResult
@Test void isValidMeasurement_whenKnownOrUnknownUnit_returnsExpectedResult()Checks measurement validity, metric and imperial detection. -
isMetricUnit_whenSource_returnsExpectedResult
@Test void isMetricUnit_whenSource_returnsExpectedResult()Checks metric unit detection in strings. -
isImperialUnit_whenSource_returnsExpectedResult
@Test void isImperialUnit_whenSource_returnsExpectedResult()Checks imperial unit detection in strings. -
getUnitSystem_whenSource_returnsDetectedSystem
@Test void getUnitSystem_whenSource_returnsDetectedSystem()Checks unit system detection from strings. -
getUnitSystem_whenNoSource_returnsLocaleSystem
@Test void getUnitSystem_whenNoSource_returnsLocaleSystem()Checks that the formatter locale determines its default unit system. -
parse_whenKnownUnit_returnsPressure
Checks parsing of every unit, including kPa not being mistaken for Pa.- Throws:
ParseExceptionUnknownUnitException
-
parse_whenUnknownUnit_throwsUnknownUnitException
@Test void parse_whenUnknownUnit_throwsUnknownUnitException()Checks that an unknown unit fails parsing. -
parse_whenNoNumber_throwsParseException
@Test void parse_whenNoNumber_throwsParseException()Checks that a string without a number fails parsing. -
findUnit_whenSource_returnsDetectedUnit
@Test void findUnit_whenSource_returnsDetectedUnit()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.
-