Skip to content

Add comprehensive test coverage for BoundingBox, PointInImage, SNTColor, LinAlgUtils, StrahlerAnalyzer, and PathStatistics#281

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/add-test-coverage-analysis
Draft

Add comprehensive test coverage for BoundingBox, PointInImage, SNTColor, LinAlgUtils, StrahlerAnalyzer, and PathStatistics#281
Copilot wants to merge 1 commit intomainfrom
copilot/add-test-coverage-analysis

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 7, 2026

Summary

Adds 6 new test files targeting areas of the codebase with no existing tests. Before this PR there were 20 test files covering 369 source files (~5.4% test-to-source ratio); this PR adds 6 new test classes with ~200 individual test cases.

New Test Files

sc.fiji.snt.util.PointInImageTest

Covers the core geometric point class:

  • Distance calculations (Euclidean, squared Euclidean, Chebyshev XY/Z/3D)
  • isReal() for NaN/Infinite coordinate detection
  • isSameLocation() comparison
  • scale() coordinate transformation
  • getCoordinateOnAxis() with valid/invalid axis values
  • equals(), hashCode(), clone() contract

sc.fiji.snt.util.BoundingBoxTest

Covers the bounding box utility:

  • Default and point-cloud constructors
  • compute(), append(), combine(), intersection()
  • contains(BoundingBox), contains(SNTPoint), contains2D(SNTPoint)
  • getDimensions(), getDiagonal(), getCentroid()
  • scale(), shift() spatial transformations
  • isScaled(), hasDimensions(), setDimensions() (including error case)
  • sanitizedUnit() for various string inputs (null, "pixels", "um", "micron", custom)
  • equals(), hashCode(), clone()

sc.fiji.snt.util.SNTColorTest

Covers the color utility class:

  • colorToString() for null, AWT Color, and ColorRGB inputs
  • fromHex() for 6-digit, 8-digit, hash-prefixed, and named color strings
  • fromString() consistency with fromHex()
  • average() for empty, single, two-color, and null-containing collections
  • interpolateNullEntries() for middle nulls, null array, and all-null cases
  • alphaColor() for 0%, 50%, 100% and null input
  • contrastColor() for dark and light inputs
  • getDistinctColors(), getDistinctColorsHex(), getDistinctColorsAWT() with various counts and excluded hues

sc.fiji.snt.util.LinAlgUtilsTest

Covers the linear algebra utility:

  • Reflection across XY, XZ, and YZ planes
  • Points on the plane are unchanged by reflection
  • Involutory property: reflecting twice returns the original point
  • Matrix dimensions (4×4 homogeneous) and last-row correctness

sc.fiji.snt.analysis.StrahlerAnalyzerTest

Covers Horton-Strahler analysis on the demo fractal tree:

  • getRootNumber() correctness and consistency with TreeStatistics.getStrahlerNumber()
  • getHighestBranchOrder() bounds
  • getBranchCounts(), getLengths(), getBranchPointCounts() map structure and value validity
  • getBifurcationRatios() — NaN for highest order, positive for lower orders, avg = 2 for fractal tree
  • getBranches() for all valid orders; IllegalArgumentException for out-of-range orders
  • getAvgFragmentations(), getAvgContractions(), getGraph(), getRootAssociatedBranches()

sc.fiji.snt.analysis.PathStatisticsTest

Covers path-level morphometric analysis:

  • Single-path and multi-path construction
  • getNBranches(), getBranches() count
  • getMetric(String) for Path ID (single vs. multi path)
  • getMetric(String, Path) for length, node count, and children count
  • getPrimaryBranches(), getTerminalBranches(), getInnerBranches()
  • getPrimaryLength(), getTerminalLength(), getInnerLength()
  • getCableLength() consistency with individual path lengths
  • Manual path with known geometry (3-4-0 triangle → length 5)

…r, LinAlgUtils, StrahlerAnalyzer, and PathStatistics

Agent-Logs-Url: https://github.com/morphonets/SNT/sessions/2f9534b0-79d5-45c3-b9b7-1922e6e743f4

Co-authored-by: tferr <2439948+tferr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants