Class TimeTest

java.lang.Object
org.djunits.quantity.TimeTest

class TimeTest extends Object
TimeTest tests the Time 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 Time constructors
  • Parsing: valueOf and of
  • Reference creation, lookup, and simple offset transformations
  • Arithmetic operations: subtract(Time), add(Duration), subtract(Duration)
  • Display-unit propagation rules
  • Inherited operations from AbsoluteQuantity: comparisons, zero checks, interpolate, sum, mean, min, max
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 subtract(Time) → Duration, add(Duration) → Time, subtract(Duration) → Time, and check display-unit propagation from the absolute quantity.
    (package private) void
    Test lt, le, gt, ge, eq, ne, compareTo.
    (package private) void
    Test all Time constructors: (value, unit, reference), (value, abbreviation, reference), and (Duration, reference), as well as ofSi(..., reference).
    (package private) void
    Test parsing of textual values via valueOf(text, reference) and of(value, unitString, reference), including error paths.
    (package private) void
    Test Reference.get for built-ins and simple add/get with offset.
    (package private) void
    Test the static operations inherited from AbsoluteQuantity: interpolate, min, max, sum, and mean, using the same reference.
    (package private) void
    Test lt0, le0, gt0, ge0, eq0, ne0 and numeric Number conversions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimeTest

      TimeTest()
  • Method Details

    • setup

      @BeforeEach final void setup()
      Set Locale.US for consistent number parsing and formatting.
    • testConstructors

      @Test void testConstructors()
      Test all Time constructors: (value, unit, reference), (value, abbreviation, reference), and (Duration, reference), as well as ofSi(..., reference).
    • testParsing

      @Test void testParsing()
      Test parsing of textual values via valueOf(text, reference) and of(value, unitString, reference), including error paths.
    • testReferenceBehavior

      @Test void testReferenceBehavior()
      Test Reference.get for built-ins and simple add/get with offset. Also verify relativeTo(...) for a single-level offset, and that unrelated built-ins (with no defined path) cannot be transformed.
    • testArithmetic

      @Test void testArithmetic()
      Test subtract(Time) → Duration, add(Duration) → Time, subtract(Duration) → Time, and check display-unit propagation from the absolute quantity.
    • testComparisonOperators

      @Test void testComparisonOperators()
      Test lt, le, gt, ge, eq, ne, compareTo. Mismatched references should throw.
    • testZeroComparisonsAndNumericConversions

      @Test void testZeroComparisonsAndNumericConversions()
      Test lt0, le0, gt0, ge0, eq0, ne0 and numeric Number conversions.
    • testStaticOperations

      @Test void testStaticOperations()
      Test the static operations inherited from AbsoluteQuantity: interpolate, min, max, sum, and mean, using the same reference. Mixed references should throw.