Class TorqueTest

java.lang.Object
org.djunits.quantity.TorqueTest

class TorqueTest extends Object
TorqueTest tests the Torque quantity class.

This test suite verifies:

  • Constructors, constants, copy behavior, and SI conversions
  • String parsing and all parsing-related error branches
  • Arithmetic operations (divide and multiply) producing correct quantities
  • Unit conversions, including imperial units (lbf·ft, lbf·in) and kilogram-force meters
  • Unit derivation behavior—including linear unit derivation and the exception path for non-linear scale derivation
  • Proper resolution of units through the Units registry
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 a predictable locale before each test.
    (package private) void
    Test constructors, constants, string parsing, SI conversions, instantiate, siUnit(), and ofSi().
    (package private) void
    Test all arithmetic operations provided by Torque.
    (package private) void
    Test all parsing error branches: null, empty, unknown unit, malformed numeric value, and of() error paths.
    (package private) void
    Test unit derivation.
    (package private) void
    Test correctness of unit conversions for Nm, meter-kilogram-force, pound-foot, and pound-inch.

    Methods inherited from class java.lang.Object

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

    • TorqueTest

      TorqueTest()
  • Method Details

    • setup

      @BeforeEach final void setup()
      Set a predictable locale before each test.
    • testBasics

      @Test void testBasics()
      Test constructors, constants, string parsing, SI conversions, instantiate, siUnit(), and ofSi().
    • testParsingErrors

      @Test void testParsingErrors()
      Test all parsing error branches: null, empty, unknown unit, malformed numeric value, and of() error paths.
    • testUnitConversions

      @Test void testUnitConversions()
      Test correctness of unit conversions for Nm, meter-kilogram-force, pound-foot, and pound-inch. Also verifies registry resolution behavior.
    • testOperations

      @Test void testOperations()
      Test all arithmetic operations provided by Torque.
      • divide(Torque)
      • divide(Force) → Length
      • divide(Length) → Force
      • multiply(LinearObjectDensity) → Force
      • divide(Duration) → Power
      • divide(Power) → Duration
      • multiply(Frequency) → Power
      • divide(Volume) → Pressure
      • divide(Pressure) → Volume
    • testUnitBehavior

      @Test void testUnitBehavior()
      Test unit derivation.
      • Deriving a linear unit
      • Exception branch for non-linear scale derivation
      • ofSi delegation