Package org.djunits.vecmat.storage
Class DenseFloatDataSiTest
java.lang.Object
org.djunits.vecmat.storage.DenseFloatDataSiTest
Unit tests for
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.
DenseFloatDataSi.
This test class verifies the complete functional behavior of DenseFloatDataSi and all default methods inherited from
DataGridSi. All tests focus on correct functional semantics. If the implementation contains bugs or produces
incorrect results, these tests are designed to fail.
- All constructors (float[], float[][], Q[][])
- Bounds checking on
get(int,int) - All default
DataGridmethods:getRowArray,getColArray - Copy semantics
- Instantiations via
instantiateNew - Cardinality behavior
- Equality and hashCode
- SI-conversion correctness for Q[][] (using Length)
- Float → double copying correctness in
getDataArray()
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidTest cardinality semantics: counts non-zero entries; counts NaN and infinity as non-zero.voidtestCopy()Test deep copy semantics ofcopy().voidTest constructor(float[][]) for safe-copy semantics, validation, row-major correctness, and ragged-row exact exception class.voidTest validation paths for constructor(float[],r,c).voidTest constructor(Q[][]) for safe-copy, SI conversion, and ragged detection.voidTest equals and hashCode semantics.voidTestgetColArrayincluding bounds checking.voidVerify thatgetDataArray()returns a *new* double array each call and does not expose the internal float[].voidTest all out-of-bounds read conditions.voidTestgetRowArrayincluding bounds checking.voidTestinstantiateNew(double[], r, c)for correct reshape and error handling.voidTestinstantiateNew(double[])conversion double→float and geometry preservation.voidTestrows(),cols(), andget(int,int)for normal behavior.
-
Constructor Details
-
DenseFloatDataSiTest
public DenseFloatDataSiTest()
-
-
Method Details
-
testRowsColsGet
@Test @DisplayName("rows/cols/get: happy-path read access") public void testRowsColsGet()Testrows(),cols(), andget(int,int)for normal behavior. -
testGetOutOfBounds
@Test @DisplayName("get: bounds checking exceptions") public void testGetOutOfBounds()Test all out-of-bounds read conditions. -
testGetRowArray
@Test @DisplayName("DataGrid.getRowArray: normal and error paths") public void testGetRowArray()TestgetRowArrayincluding bounds checking. -
testGetColArray
@Test @DisplayName("DataGrid.getColArray: normal and error paths") public void testGetColArray()TestgetColArrayincluding bounds checking. -
testGetDataArrayCopy
@Test @DisplayName("getDataArray: returns new array every time; not exposing internals") public void testGetDataArrayCopy()Verify thatgetDataArray()returns a *new* double array each call and does not expose the internal float[]. -
testCopy
@Test @DisplayName("copy: deep-copy of internal float array") public void testCopy()Test deep copy semantics ofcopy(). -
testInstantiateNewSameDims
@Test @DisplayName("instantiateNew(double[]): shape preserved, float cast correct") public void testInstantiateNewSameDims()TestinstantiateNew(double[])conversion double→float and geometry preservation. -
testInstantiateNewNewDims
@Test @DisplayName("instantiateNew(double[],r,c): reshape + float casting") public void testInstantiateNewNewDims()TestinstantiateNew(double[], r, c)for correct reshape and error handling. -
testCardinality
@Test @DisplayName("cardinality: float rules incl. -0f, NaN, infinities") public void testCardinality()Test cardinality semantics: counts non-zero entries; counts NaN and infinity as non-zero. -
testEqualsHashCode
@Test @DisplayName("equals/hashCode: reflexivity, symmetry, difference detection") public void testEqualsHashCode()Test equals and hashCode semantics. -
testCtorFloatArrayValidation
@Test @DisplayName("ctor(float[],r,c): validation of null, size, geometry") public void testCtorFloatArrayValidation()Test validation paths for constructor(float[],r,c). -
testCtor2DFloatArray
@Test @DisplayName("ctor(float[][]): validation, safe copy, row-major, ragged detection") public void testCtor2DFloatArray()Test constructor(float[][]) for safe-copy semantics, validation, row-major correctness, and ragged-row exact exception class. -
testCtorQuantityArray
@Test @DisplayName("ctor(Q[][]): SI conversion, safe copy, ragged detection") public void testCtorQuantityArray()Test constructor(Q[][]) for safe-copy, SI conversion, and ragged detection.
-