Skip to content

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

Open
nickzerjeski wants to merge 1 commit intoTheAlgorithms:masterfrom
nickzerjeski:test-iterative-binary-search-null-cases-7330
Open

test(searches): cover null input cases in IterativeBinarySearch#7375
nickzerjeski wants to merge 1 commit 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 Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.51%. Comparing base (1edf319) to head (169fcdd).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7375      +/-   ##
============================================
+ Coverage     79.50%   79.51%   +0.01%     
- Complexity     7142     7144       +2     
============================================
  Files           796      796              
  Lines         23368    23368              
  Branches       4596     4596              
============================================
+ Hits          18578    18581       +3     
+ Misses         4050     4049       -1     
+ Partials        740      738       -2     

☔ 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.

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

3 participants