Class DenseDoubleDataSiTest

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

public class DenseDoubleDataSiTest extends Object
Unit tests for DenseDoubleDataSi.

This test class verifies the functional behavior of DenseDoubleDataSi and the default methods in the DataGridSi interface:

  • Constructors: double[], double[][], and Q[][] (SI values)
  • Accessors: rows(), cols(), get(int,int), getDataArray()
  • Default methods in DataGridSi: getRowArray(int), getColArray(int) including bounds checks
  • Copy and instantiation: copy(), instantiateNew(double[]), instantiateNew(double[],int,int)
  • Cardinality semantics, including 0.0, -0.0, NaN, and infinities
  • Equality and hash code contracts
  • All branches and all exception paths

Tests assert functional intent; if the implementation is incorrect, these tests will fail by design.
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

    • DenseDoubleDataSiTest

      public DenseDoubleDataSiTest()
  • Method Details

    • testRowsColsAndGet

      @Test @DisplayName("rows/cols/get: happy path for 2x3") public void testRowsColsAndGet()
      Verify basic getters rows(), cols(), and get(int,int) on a simple 2x3 matrix.
    • testGetOutOfBounds

      @Test @DisplayName("get: index bounds checking") public void testGetOutOfBounds()
      Verify that get(int,int) throws for all out-of-bounds row/col combinations.
    • testGetRowArray

      @Test @DisplayName("DataGrid.getRowArray: happy path + bounds") public void testGetRowArray()
      Verify that DataGridSi.getRowArray(int) returns a dense copy with correct values and enforces bounds.
    • testGetColArray

      @Test @DisplayName("DataGrid.getColArray: happy path + bounds") public void testGetColArray()
      Verify that DataGridSi.getColArray(int) returns a dense copy with correct values and enforces bounds.
    • testGetDataArrayExposure

      @Test @DisplayName("getDataArray: exposes internal array (by design)") public void testGetDataArrayExposure()
      Verify exposure semantics of DenseDoubleDataSi.getDataArray() (no safe copy). Modifications through the returned array are reflected in the object, by design.
    • testCopy

      @Test @DisplayName("copy: deep copy of data and identical geometry") public void testCopy()
      Verify DenseDoubleDataSi.copy() creates a deep copy (independent backing array).
    • testInstantiateNewSameDims

      @Test @DisplayName("instantiateNew(double[]): shape preserved, backing exposed") public void testInstantiateNewSameDims()
      Verify DenseDoubleDataSi.instantiateNew(double[]) returns a new instance with same shape and exposed backing.
    • testInstantiateNewNewDims

      @Test @DisplayName("instantiateNew(double[], r, c): new shape and length checks") public void testInstantiateNewNewDims()
      Verify DenseDoubleDataSi.instantiateNew(double[], int, int) for new shape and argument validation.
    • testCardinality

      @Test @DisplayName("cardinality: zero, -zero, NaN, +/-infinity") public void testCardinality()
      Verify DenseDoubleDataSi.cardinality() semantics: counts non-zero entries (treats +/-0.0 as zero; counts NaN and infinities as non-zero).
    • testEqualsHashCode

      @Test @DisplayName("equals/hashCode: reflexive, symmetric, and data/shape sensitive") public void testEqualsHashCode()
      Verify equality and hash code contracts.
    • testCtorDoubleArrayValidationAndExposure

      @Test @DisplayName("ctor(double[], r, c): validation and exposure semantics") public void testCtorDoubleArrayValidationAndExposure()
      Verify constructor with double[] validates inputs and sets geometry and backing reference as specified (no safe copy).
    • testCtor2DArrayValidationCopyingAndOrder

      @Test @DisplayName("ctor(double[][]): validation, safe copy, row-major, ragged exact-exception") public void testCtor2DArrayValidationCopyingAndOrder()
      Verify constructor with double[][] validates inputs, performs a safe copy, and preserves row-major ordering. Additionally, assert the exact exception type for ragged rows to surface the current format-string bug.
    • testCtorQuantity2DArraySIConversion

      @Test @DisplayName("ctor(Q[][]): validation, safe copy, SI conversion, ragged exact-exception") public void testCtorQuantity2DArraySIConversion()
      Verify constructor with Q[][] validates inputs, performs a safe copy, and writes SI values; unit conversions must be respected (e.g., km to m, cm to m). Additionally, assert the exact exception type for ragged rows to surface the current format-string bug.