Class TemperatureTest

java.lang.Object
org.djunits.quantity.TemperatureTest

class TemperatureTest extends Object
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)
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
Author:
Alexander Verbraeck (specifications); Test implementation by Copilot.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) final void
    Set Locale.US for consistent number parsing and formatting.
    (package private) void
    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.
    (package private) void
    Test addition and subtraction of relative quantities, subtraction of absolute temperatures, and correct propagation of display units.
    (package private) void
    Test lt, le, gt, ge, eq, ne, compareTo, and mismatched-reference error cases.
    (package private) void
    Test 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) void
    Test static constructors ofSi, valueOf, and of, including correct interpretation of unit strings, handling of references, and error paths.
    (package private) void
    Test the aggregate static operations defined in AbsoluteQuantity: max, min, sum, mean, and interpolate.
    (package private) void
    Test the lazy initializer for temperature references.
    (package private) void
    Test the behavior of Temperature.Unit, including lazy reference initialization, derived-unit creation, base/SI-unit behavior, and error handling.
    (package private) void
    Test eq0, ne0, lt0, le0, gt0, ge0 and verify that Number conversions (intValue, longValue, floatValue, doubleValue) match SI values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.