Package org.djunits.quantity
Class PositionTest
java.lang.Object
org.djunits.quantity.PositionTest
PositionTest tests the Position 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 Position constructors
- Parsing: valueOf and of
- Reference creation, lookup, and simple offset chaining
- Arithmetic operations: subtract(Position), add(Length), subtract(Length)
- 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(Position) → Length, add(Length) → Position, subtract(Length) → Position, and check that display units propagate correctly from the absolute quantity.(package private) voidTest lt, le, gt, ge, eq, ne, compareTo, including mismatched-reference errors.(package private) voidTest all Position constructors: (value, unit, reference), (value, abbreviation, reference), and (Length, reference).(package private) voidTest parsing of textual values via valueOf(text, ref) and of(value, unitString, ref).(package private) voidTest that Position.Reference.add and get work, and test simple reference offset transformations with relativeTo.(package private) voidTest the static operations inherited from AbsoluteQuantity: interpolate, min, max, sum, and mean.(package private) voidTest lt0, le0, gt0, ge0, eq0, ne0 and numeric Number conversions.
-
Constructor Details
-
PositionTest
PositionTest()
-
-
Method Details
-
setup
@BeforeEach final void setup()Set Locale.US for consistent number parsing and formatting. -
testConstructors
@Test void testConstructors()Test all Position constructors: (value, unit, reference), (value, abbreviation, reference), and (Length, reference). -
testParsing
@Test void testParsing()Test parsing of textual values via valueOf(text, ref) and of(value, unitString, ref). -
testReferenceBehavior
@Test void testReferenceBehavior()Test that Position.Reference.add and get work, and test simple reference offset transformations with relativeTo. -
testArithmetic
@Test void testArithmetic()Test subtract(Position) → Length, add(Length) → Position, subtract(Length) → Position, and check that display units propagate correctly from the absolute quantity. -
testComparisonOperators
@Test void testComparisonOperators()Test lt, le, gt, ge, eq, ne, compareTo, including mismatched-reference errors. -
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.
-