Fix ECC level Q for micro QR codes; add various tests to improve code coverage by Shane32 · Pull Request #649 · Shane32/QRCoder (original) (raw)

📝 Walkthrough

Walkthrough

Adds extensive unit tests for OneTimePassword, Slovenian UPN QR, Swiss QR Code, and micro/QR generator behaviors; introduces a guard in QRCodeGenerator.GenerateMicroQrCode to auto-select Micro version M4 for ECCLevel.Q when no version is requested. No API signature changes.

Changes

Cohort / File(s) Summary
OneTimePassword testsQRCoderTests/PayloadGeneratorTests/OneTimePasswordTests.cs Adds comprehensive OTP URI tests: input validation (null/empty/whitespace secret, colon in issuer/label, missing period for TOTP), HOTP/TOTP variants, counter edge cases, period/digits/algorithm defaults vs explicit, escaping/encoding rules, whitespace stripping, large values, and SHA512 scenarios.
Slovenian UPN QR testsQRCoderTests/PayloadGeneratorTests/SlovenianUpnQrTests.cs New test suite for Slovenian UPN QR payloads: multiline payload format, deadline handling (present/empty/null), custom codes, recipient model/reference formatting and truncation, payer/description length limits, amount formatting/rounding, checksum placement, whitespace trimming, uppercasing/normalization, and QR defaults.
Swiss QR Code testsQRCoderTests/PayloadGeneratorTests/SwissQrCodeTests.cs Adds many Swiss QR tests: combined/structured address generation, field validations (empty/length/illegal chars/country/zip/street/house no), QR-IBAN vs reference-type constraints (QRR/SCOR/NON), Liechtenstein IBAN handling, bill/additional info formatting, end-line behavior, and expected error messages.
QR generator testsQRCoderTests/QRGeneratorTests.cs Adds micro/QR data-length and ECC/version tests: data-too-long cases (any/selected versions), invalid micro versions, unsupported ECC levels, null plaintext, invalid ECC casts, and auto-selection behavior for M4 when ECCLevel.Q requested.
QR code generation logicQRCoder/QRCodeGenerator.cs Adds guard in GenerateMicroQrCode to auto-select Micro QR version M4 when ECCLevel.Q is requested and no explicit version provided (requestedVersion == 0), avoiding a thrown error and allowing Q-level Micro QR generation via implicit M4 selection.

Sequence Diagram(s)

sequenceDiagram participant Caller participant QRCodeGenerator

Caller->>QRCodeGenerator: GenerateMicroQrCode(data, ECCLevel = Q, requestedVersion = 0)
alt requestedVersion == 0 and ECCLevel == Q
    QRCodeGenerator->>QRCodeGenerator: set requestedVersion = -4 (select M4)
    Note right of QRCodeGenerator#lightgreen: Implicit M4 selection for ECC Q
end
QRCodeGenerator->>QRCodeGenerator: validate version vs ECC
QRCodeGenerator-->>Caller: generate Micro QR (M4) or throw if invalid

Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement

Suggested reviewers

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.

✅ Passed checks (2 passed)

Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely summarizes the primary fix to support ECC level Q in micro QR codes and the extensive addition of tests to improve code coverage, which directly aligns with the changes in both production logic and test suites.

✨ Finishing touches


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.