Class PositionTest

java.lang.Object
org.djunits.quantity.PositionTest

class PositionTest extends Object
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
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(Position) → Length, add(Length) → Position, subtract(Length) → Position, and check that display units propagate correctly from the absolute quantity.
    (package private) void
    Test lt, le, gt, ge, eq, ne, compareTo, including mismatched-reference errors.
    (package private) void
    Test all Position constructors: (value, unit, reference), (value, abbreviation, reference), and (Length, reference).
    (package private) void
    Test parsing of textual values via valueOf(text, ref) and of(value, unitString, ref).
    (package private) void
    Test that Position.Reference.add and get work, and test simple reference offset transformations with relativeTo.
    (package private) void
    Test the static operations inherited from AbsoluteQuantity: interpolate, min, max, sum, and mean.
    (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

    • 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.