Class SparseDoubleDataSiTest

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

public class SparseDoubleDataSiTest extends Object
Unit tests for SparseDoubleDataSi.

This test class achieves full branch coverage of all constructors, helper methods, index validation, sparse storage generation, DataGrid default methods, binary-search access path, copy semantics, instantiation operations, equals/hashCode, and all Q-based constructors, including SI-conversion. 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

    • SparseDoubleDataSiTest

      public SparseDoubleDataSiTest()
  • Method Details

    • testProtectedConstructor

      @Test @DisplayName("protected ctor(double[],indexes,r,c): validates length, order, bounds") public void testProtectedConstructor()
      Test protected constructor(double[], int[], r, c) via reflection-like access through copy().
    • testLengthErrors

      @Test public void testLengthErrors()
      Test length errors.
    • testCtorDenseData

      @Test @DisplayName("ctor(double[],r,c): basic sparse conversion + validation") public void testCtorDenseData()
      Test constructor(double[],r,c) and sparse conversion.
    • testCtorMatrix

      @Test @DisplayName("ctor(double[][]): ragged detection + safe copy + sparse") public void testCtorMatrix()
      Test constructor(double[][]) including ragged checking and safe-copy semantics.
    • testCtorQArraySparse

      @Test @DisplayName("ctor(Q[],indexes,r,c): SI conversion + safe copies") public void testCtorQArraySparse()
      Test constructor(Q[], indexes, rows, cols) with SI-conversion and validation.
    • testCtorQArrayDense

      @Test @DisplayName("ctor(Q[],r,c): full dense array -> sparse") public void testCtorQArrayDense()
      Test constructor(Q[], rows, cols) and verify no size check and correct sparse generation.
    • testCtorMatrixQ

      @Test @DisplayName("ctor(Q[][]): SI conversion + sparse + ragged detection") public void testCtorMatrixQ()
      Test constructor(Q[][]) incl. ragged detection, SI conversion, and safe copies.
    • testCtorCollection

      @Test @DisplayName("ctor(Collection<DoubleSparseValue>): index validation + SI") public void testCtorCollection()
      Test constructor(Collection) including bounds errors and SI conversion.
    • testGetAndGetDataArray

      @Test @DisplayName("get/getDataArray: binary search hit/miss + safe copy") public void testGetAndGetDataArray()
      Test getDataArray generates dense layout correctly and is a safe copy.
    • testDefaultRowColMethods

      @Test @DisplayName("DataGrid.getRowArray and getColArray work and check bounds") public void testDefaultRowColMethods()
      Test DataGrid.getRowArray and getColArray.
    • testCopy

      @Test @DisplayName("copy(): deep copy of sparseData and indexes") public void testCopy()
      Test deep copy of sparseData and indexes.
    • testInstantiateNew

      @Test @DisplayName("instantiateNew: reshape + validation") public void testInstantiateNew()
      Test instantiateNew method.
    • testCardinality

      @Test @DisplayName("cardinality: counts non-zero sparse entries") public void testCardinality()
      Test cardinality method.
    • testEqualsHashCode

      @Test @DisplayName("equals/hashCode: correct semantics") public void testEqualsHashCode()
      Test equals() and hashCode().