Class UnitSystemTest

java.lang.Object
org.djunits.unit.system.UnitSystemTest

public final class UnitSystemTest extends Object
Tests for UnitSystem.

Validates the predefined static instances, constructor validation for user-defined systems, basic semantics (getters and toString), and integration with SIUnit.getUnitSystem(). 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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Equality/hashCode minimal contracts (identity-based unless overridden).
    - Reflexivity (x.equals(x))
    - Distinct user-defined instances are not the same reference; equals may or may not be overridden.
    void
    Integration test: SIUnit.getUnitSystem() should report an SI-based system (e.g., SI_BASE).
    void
    Predefined systems must be present, non-null, and have non-empty id and name.
    void
    Constructor validation for user-defined systems.
    - null id/name → NullPointerException
    - empty/blank id/name → IllegalArgumentException
    - valid id/name → getters return the same, toString non-empty

    Methods inherited from class java.lang.Object

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

    • UnitSystemTest

      public UnitSystemTest()
  • Method Details

    • testPredefinedSystems

      @Test @DisplayName("Predefined UnitSystems: existence and non-empty metadata") public void testPredefinedSystems()
      Predefined systems must be present, non-null, and have non-empty id and name. The toString() should be stable and non-empty.
    • testUserDefinedConstructorValidation

      @Test @DisplayName("User-defined UnitSystem: constructor validation and semantics") public void testUserDefinedConstructorValidation()
      Constructor validation for user-defined systems.
      - null id/name → NullPointerException
      - empty/blank id/name → IllegalArgumentException
      - valid id/name → getters return the same, toString non-empty
    • testEqualityContracts

      @Test @DisplayName("Equality/hashCode: reflexivity and distinct instances") public void testEqualityContracts()
      Equality/hashCode minimal contracts (identity-based unless overridden).
      - Reflexivity (x.equals(x))
      - Distinct user-defined instances are not the same reference; equals may or may not be overridden.
    • testIntegrationWithSIUnit

      @Test @DisplayName("Integration with SIUnit: getUnitSystem() returns SI_BASE") public void testIntegrationWithSIUnit()
      Integration test: SIUnit.getUnitSystem() should report an SI-based system (e.g., SI_BASE).