Skip to content

Add barcode module tests#1864

Merged
shimat merged 2 commits into
mainfrom
add_barcode_tests
Apr 27, 2026
Merged

Add barcode module tests#1864
shimat merged 2 commits into
mainfrom
add_barcode_tests

Conversation

@shimat
Copy link
Copy Markdown
Owner

@shimat shimat commented Apr 27, 2026

Summary by CodeRabbit

  • Tests
    • Added comprehensive tests for the BarcodeDetector covering construction, input validation, and detection behavior. Verifies handling of null inputs, small images, grayscale images, plain white images, and synthetic striped patterns, plus regression checks to ensure output consistency and prevent regressions.

@shimat shimat self-assigned this Apr 27, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de5a57a9-750b-403a-938d-189bd2c7c8ce

📥 Commits

Reviewing files that changed from the base of the PR and between 06e5422 and f9f66f4.

📒 Files selected for processing (1)
  • test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs

📝 Walkthrough

Walkthrough

Adds an xUnit test suite BarcodeDetectorTest validating BarcodeDetector construction, null-argument handling, setter methods, and detection behavior on plain, small, grayscale, and synthetic striped images; includes a helper to draw striped test mats.

Changes

Cohort / File(s) Summary
BarcodeDetector Test Suite
test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs
New 182-line test class adding constructor checks, ArgumentNullException tests for DetectAndDecode and SetDetectorScales, setter smoke tests (SetDownsamplingThreshold, SetGradientThreshold, SetDetectorScales), functional tests on white, small (30x30), and grayscale images, a regression striped-image test asserting output length consistency, and a helper to draw vertical stripes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add barcode module tests' directly and clearly summarizes the main change: introducing a new test suite for the barcode module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add_barcode_tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs (1)

147-148: Swap argument order to follow xUnit Assert.Equal(expected, actual) convention.

Assert.Equal treats the first argument as the expected value and the second as the actual value; this affects the failure message only, but matters when the assertion eventually fails. The invariant here is "there are 4 corner points per detected result", so the natural reading is actual=points.Length, expected=results.Length * 4.

♻️ Proposed fix
-        Assert.Equal(points.Length, results.Length * 4);
-        Assert.Equal(results.Length, types.Length);
+        Assert.Equal(results.Length * 4, points.Length);
+        Assert.Equal(types.Length, results.Length);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs` around lines 147 -
148, Swap the argument order for the two Assert.Equal calls so the first
argument is the expected value and the second is the actual: for the corners
assertion use expected = results.Length * 4 and actual = points.Length, and for
the types-length assertion use expected = results.Length and actual =
types.Length; update the two Assert.Equal(...) calls accordingly (referencing
Assert.Equal, points, results, and types).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs`:
- Around line 147-148: Swap the argument order for the two Assert.Equal calls so
the first argument is the expected value and the second is the actual: for the
corners assertion use expected = results.Length * 4 and actual = points.Length,
and for the types-length assertion use expected = results.Length and actual =
types.Length; update the two Assert.Equal(...) calls accordingly (referencing
Assert.Equal, points, results, and types).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a306d136-956f-4cab-84c6-f8e77cc2b250

📥 Commits

Reviewing files that changed from the base of the PR and between 9ea30e6 and 06e5422.

📒 Files selected for processing (1)
  • test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs

Comment thread test/OpenCvSharp.Tests/barcode/BarcodeDetectorTest.cs Outdated
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