Skip to content

test: add algorithm unit tests and enforce 85% coverage gate#4

Merged
beingmartinbmc merged 1 commit into
feat/algorithms-data-structures-expansionfrom
test/algorithm-coverage-ci-gate
Jun 12, 2026
Merged

test: add algorithm unit tests and enforce 85% coverage gate#4
beingmartinbmc merged 1 commit into
feat/algorithms-data-structures-expansionfrom
test/algorithm-coverage-ci-gate

Conversation

@beingmartinbmc

Copy link
Copy Markdown
Owner

Summary

Adds the missing algorithm unit tests, lifts all algorithm folders above 90% coverage, and wires an 85% coverage gate into CI.

Tests added

  • tree/algorithms/__tests__/generator.test.tsgenerateRandomTree, getTreeNodes, getTreeEdges (node counts, value/id uniqueness, layout, n−1 edges, empty/edge cases). 0% → 100%.
  • linked-list/algorithms/__tests__/randomInput.test.ts — every problem branch (×40 runs each to beat internal Math.random()), outputs fed back into the step builder, LRU/cycle/palindrome format checks. 0% → 100%.
  • Extended pathfinding.test.ts with large-open-grid, boxed-in start, and sealed-region cases.

Source tweaks

  • Removed dead code in dijkstra.ts (distance === Infinity break could never fire).
  • Annotated defensive stale-heap guards in dijkstra.ts / astar.ts with /* v8 ignore */ (unreachable under uniform edge weights) → graph 100%.

CI gate

  • vitest.config.ts: coverage.thresholds of 85% for statements/branches/functions/lines.
  • ci.yml: new "Tests + coverage (min 85%)" step between typecheck and build.

Final coverage (171 tests passing)

Area Stmts Branch
All files 98.96% 95.3%
sorting 100% 100%
graph 100% 100%
linked-list 98.1% 93.5%
tree 100% 97.2%

- Add generator and randomInput test suites (previously 0% covered)
- Add sorting, linked-list, graph pathfinding, and tree traversal tests
- Remove dead branch in dijkstra; annotate defensive stale-heap guards
- Configure vitest v8 coverage thresholds (85% across all metrics)
- Run test:coverage in CI between typecheck and build

All algorithm folders now >90% coverage (graph 100%).
@beingmartinbmc beingmartinbmc merged commit 0f8ccb9 into feat/algorithms-data-structures-expansion Jun 12, 2026
beingmartinbmc added a commit that referenced this pull request Jul 5, 2026
…gate

test: add algorithm unit tests and enforce 85% coverage gate
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.

1 participant