Package org.djunits.unit.system
Class UnitSystemTest
java.lang.Object
org.djunits.unit.system.UnitSystemTest
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidEquality/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.voidIntegration test: SIUnit.getUnitSystem() should report an SI-based system (e.g., SI_BASE).voidPredefined systems must be present, non-null, and have non-empty id and name.voidConstructor validation for user-defined systems.
- null id/name → NullPointerException
- empty/blank id/name → IllegalArgumentException
- valid id/name → getters return the same, toString non-empty
-
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).
-