Package org.djunits.quantity
Class TimeTest
java.lang.Object
org.djunits.quantity.TimeTest
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
- 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 subtract(Time) → Duration, add(Duration) → Time, subtract(Duration) → Time, and check display-unit propagation from the absolute quantity.(package private) voidTest lt, le, gt, ge, eq, ne, compareTo.(package private) voidTest all Time constructors: (value, unit, reference), (value, abbreviation, reference), and (Duration, reference), as well as ofSi(..., reference).(package private) voidTest parsing of textual values via valueOf(text, reference) and of(value, unitString, reference), including error paths.(package private) voidTest Reference.get for built-ins and simple add/get with offset.(package private) voidTest the static operations inherited from AbsoluteQuantity: interpolate, min, max, sum, and mean, using the same reference.(package private) voidTest lt0, le0, gt0, ge0, eq0, ne0 and numeric Number conversions.
-
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.
-