Package org.djunits.quantity
Class TemperatureTest
java.lang.Object
org.djunits.quantity.TemperatureTest
TemperatureTest tests the Temperature absolute quantity class and its Reference handling.
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUNITS project is distributed under a https://djunits.org/docs/license.html three-clause BSD-style license.
This test suite provides comprehensive functional coverage of:
- All constructors of Temperature
- Parsing via valueOf(...) and of(...)
- Reference transformations and offset chaining
- Temperature.Unit scale behavior, lazy reference initialization, and deriveUnit()
- Arithmetic operations and display-unit propagation
- Comparison operators and zero checks
- Static aggregate operations (min, max, sum, mean, interpolate)
- Author:
- Alexander Verbraeck (specifications); Test implementation by Copilot.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final voidsetup()Set Locale.US for consistent number parsing and formatting.(package private) voidTest all Temperature constructors, ensuring that value, unit, and reference are interpreted correctly and that the correct default reference is applied when no explicit reference is provided.(package private) voidTest addition and subtraction of relative quantities, subtraction of absolute temperatures, and correct propagation of display units.(package private) voidTest lt, le, gt, ge, eq, ne, compareTo, and mismatched-reference error cases.(package private) voidTest the correctness of reference conversions using relativeTo(...), including built-in references (KELVIN, CELSIUS, FAHRENHEIT) and a dynamically added reference with its own offset.(package private) voidTest static constructors ofSi, valueOf, and of, including correct interpretation of unit strings, handling of references, and error paths.(package private) voidTest the aggregate static operations defined in AbsoluteQuantity: max, min, sum, mean, and interpolate.(package private) voidTest the lazy initializer for temperature references.(package private) voidTest the behavior of Temperature.Unit, including lazy reference initialization, derived-unit creation, base/SI-unit behavior, and error handling.(package private) voidTest eq0, ne0, lt0, le0, gt0, ge0 and verify that Number conversions (intValue, longValue, floatValue, doubleValue) match SI values.
-
Constructor Details
-
TemperatureTest
TemperatureTest()
-
-
Method Details
-
setup
@BeforeEach final void setup()Set Locale.US for consistent number parsing and formatting. -
testAllConstructors
@Test void testAllConstructors()Test all Temperature constructors, ensuring that value, unit, and reference are interpreted correctly and that the correct default reference is applied when no explicit reference is provided. -
testStaticFactoriesAndParsing
@Test void testStaticFactoriesAndParsing()Test static constructors ofSi, valueOf, and of, including correct interpretation of unit strings, handling of references, and error paths. -
testReferenceConversion
@Test void testReferenceConversion()Test the correctness of reference conversions using relativeTo(...), including built-in references (KELVIN, CELSIUS, FAHRENHEIT) and a dynamically added reference with its own offset. -
testUnitReferenceInitializationAndDeriveUnit
@Test void testUnitReferenceInitializationAndDeriveUnit()Test the behavior of Temperature.Unit, including lazy reference initialization, derived-unit creation, base/SI-unit behavior, and error handling. -
testArithmetic
@Test void testArithmetic()Test addition and subtraction of relative quantities, subtraction of absolute temperatures, and correct propagation of display units. -
testComparisonOperators
@Test void testComparisonOperators()Test lt, le, gt, ge, eq, ne, compareTo, and mismatched-reference error cases. -
testZeroComparisonsNumericConversions
@Test void testZeroComparisonsNumericConversions()Test eq0, ne0, lt0, le0, gt0, ge0 and verify that Number conversions (intValue, longValue, floatValue, doubleValue) match SI values. -
testStaticOperations
@Test void testStaticOperations()Test the aggregate static operations defined in AbsoluteQuantity: max, min, sum, mean, and interpolate. Also test reference mismatch errors. -
testTemperatureUnitLazyReferenceInit
@Test void testTemperatureUnitLazyReferenceInit()Test the lazy initializer for temperature references.
-