Skip to content

test(searches): cover null input cases in IterativeBinarySearch#7375

Merged
DenizAltunkapan merged 2 commits intoTheAlgorithms:masterfrom
nickzerjeski:test-iterative-binary-search-null-cases-7330
Apr 14, 2026
Merged

test(searches): cover null input cases in IterativeBinarySearch#7375
DenizAltunkapan merged 2 commits intoTheAlgorithms:masterfrom
nickzerjeski:test-iterative-binary-search-null-cases-7330

Conversation

@nickzerjeski
Copy link
Copy Markdown
Contributor

Description

Add regression tests for null safety behavior in IterativeBinarySearch.

The implementation already guards against null/empty inputs; this PR adds explicit unit coverage to prevent regressions.

Fixes #7330

Changes

  • Added testBinarySearchNullArray
  • Added testBinarySearchNullKey

Validation

  • mvn -q -Dtest=IterativeBinarySearchTest test

Copilot AI review requested due to automatic review settings April 13, 2026 08:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing regression coverage for IterativeBinarySearch’s existing null-safety behavior (returning -1 for null array and null key), aligning the unit suite with the implementation’s guard clauses and preventing future regressions.

Changes:

  • Added a unit test asserting find(null, key) returns -1.
  • Added a unit test asserting find(array, null) returns -1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.50%. Comparing base (df8fd85) to head (4463213).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7375   +/-   ##
=========================================
  Coverage     79.49%   79.50%           
- Complexity     7159     7161    +2     
=========================================
  Files           797      797           
  Lines         23409    23409           
  Branches       4603     4603           
=========================================
+ Hits          18609    18611    +2     
+ Misses         4054     4053    -1     
+ Partials        746      745    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) April 14, 2026 09:59
@DenizAltunkapan DenizAltunkapan merged commit 14b6f99 into TheAlgorithms:master Apr 14, 2026
7 checks passed
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.

Handle null and empty array cases in IterativeBinarySearch

4 participants