Class DenseFloatDataSiTest

java.lang.Object
org.djunits.vecmat.storage.DenseFloatDataSiTest

public class DenseFloatDataSiTest extends Object
Unit tests for 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 DataGrid methods: 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 Details

    • DenseFloatDataSiTest

      public DenseFloatDataSiTest()
  • Method Details

    • testRowsColsGet

      @Test @DisplayName("rows/cols/get: happy-path read access") public void testRowsColsGet()
      Test rows(), cols(), and get(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()
      Test getRowArray including bounds checking.
    • testGetColArray

      @Test @DisplayName("DataGrid.getColArray: normal and error paths") public void testGetColArray()
      Test getColArray including bounds checking.
    • testGetDataArrayCopy

      @Test @DisplayName("getDataArray: returns new array every time; not exposing internals") public void testGetDataArrayCopy()
      Verify that getDataArray() 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 of copy().
    • testInstantiateNewSameDims

      @Test @DisplayName("instantiateNew(double[]): shape preserved, float cast correct") public void testInstantiateNewSameDims()
      Test instantiateNew(double[]) conversion double→float and geometry preservation.
    • testInstantiateNewNewDims

      @Test @DisplayName("instantiateNew(double[],r,c): reshape + float casting") public void testInstantiateNewNewDims()
      Test instantiateNew(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.