Skip to content

cover RGB and RGBA color APIs#91

Open
DongjaJ wants to merge 7 commits into
utilForever:mainfrom
DongjaJ:issue-89-rgb-rgba-color-apis
Open

cover RGB and RGBA color APIs#91
DongjaJ wants to merge 7 commits into
utilForever:mainfrom
DongjaJ:issue-89-rgb-rgba-color-apis

Conversation

@DongjaJ
Copy link
Copy Markdown
Contributor

@DongjaJ DongjaJ commented May 15, 2026

What

Add focused unit tests for RGB and RGBA color APIs, including construction, conversions, hex parsing edge cases, arithmetic, transforms, and Bevy feature conversions.

Why

RGB/RGBA color APIs lacked direct coverage for several public conversion and parsing paths. These tests document the expected component behavior and bring rgb.rs and rgba.rs line coverage to 100% when the Bevy feature is enabled.

Closes #89

Before

before rgb test

After

after rgb 테스트

Checklist

Required

  • cargo check --all passes
  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings -A clippy::multiple-crate-versions passes
  • cargo test --all passes
  • I linked the related issue (for example: Closes #123)

Functional Validation

  • Behavior related to this change was verified locally (if applicable)
  • Rendering/backend behavior was verified when runtime code changed (if applicable)
  • Algorithm behavior (pathfinding/FOV/noise/random) was verified when affected (if applicable)
  • I added or updated tests for changed behavior (if applicable)

Configuration & Docs

  • User-facing docs were updated (README.md, ARCHITECTURE.md, or relevant manual pages, if applicable)
  • New dependencies/configuration are documented (if applicable)
  • No sensitive values or credentials were introduced

If Applicable

  • Security impact considered (run cargo audit locally if needed)
  • Breaking behavior changes are clearly described in this PR

Verification

  • cargo check --all
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings -A clippy::multiple-crate-versions
  • cargo test --all
  • cargo test -p bracket-color --features bevy
  • cargo llvm-cov -p bracket-color --features bevy --html --open

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for color conversions (RGB, RGBA, HSV) including edge cases and clamping behavior.
    • Improved hex parsing tests with more comprehensive validation scenarios.
    • Enhanced round-trip conversion testing to ensure data integrity across color formats.

Review Change Stack

DongjaJ added 7 commits May 14, 2026 16:25
Covers RGB::from_f32, RGB::from_u8, tuple/RGBA conversions, RGB::to_rgba, and XpColor conversion behavior.
Covers RGB Add/Sub/Mul operators, greyscale/desaturate helpers, and RGB::lerp boundary and midpoint behavior.
Covers RGBA conversion from RGB, RGB/RGBA byte tuples, and f32 component arrays.
Covers RGBA Add/Sub/Mul operators, RGBA::lerp midpoint behavior, and RGBA::lerp_alpha alpha-only interpolation.
Separates RGB::from_f32, RGB::from_u8, tuple conversion, and RGBA conversion into API-specific tests for clearer failures.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 50539000-bff3-45e5-bab2-f64b764e5d4d

📥 Commits

Reviewing files that changed from the base of the PR and between 5242b0e and cbadbc0.

📒 Files selected for processing (2)
  • bracket-color/src/rgb.rs
  • bracket-color/src/rgba.rs
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format all Rust code using cargo fmt --all
Fix all cargo clippy warnings — the CI enforces -D warnings
Add tests for new functionality in the relevant module; for split domains, prefer colocated tests.rs

Files:

  • bracket-color/src/rgba.rs
  • bracket-color/src/rgb.rs
🔇 Additional comments (2)
bracket-color/src/rgb.rs (1)

488-547: LGTM!

Also applies to: 579-620, 640-681, 686-715

bracket-color/src/rgba.rs (1)

508-568: LGTM!

Also applies to: 592-602, 608-619, 622-651, 692-692, 704-705


📝 Walkthrough

Walkthrough

The PR expands and restructures test coverage for RGB and RGBA color types. New parameterized tests validate conversion, arithmetic, parsing, and Bevy integration behavior; interpolation assertions are refined to use exact equality checks instead of epsilon tolerance.

Changes

Color Type Test Expansion

Layer / File(s) Summary
RGB conversion and arithmetic tests
bracket-color/src/rgb.rs
New tests for from_f32 clamping, from_u8 component conversion, tuple-to-RGB construction, RGBA-to-RGB alpha dropping, HSV delegation, and parameterized component-wise arithmetic operator behavior.
RGB transformation and parsing tests
bracket-color/src/rgb.rs
Parameterized HSV wrap-around case, multi-alpha to_rgba tests, XP round-trip and clamping tests, expanded hex parsing rejection cases via rstest, conditional Bevy color-channel preservation tests, and updated assertions for named BLUE, greyscale luminance, desaturate, and lerp interpolation.
RGBA conversion and arithmetic tests
bracket-color/src/rgba.rs
Parameterized tests for alpha fill/preserve behavior in conversions, HSV-to-RGBA opaque alpha, and component-wise arithmetic operators (add, sub, mul) with constructor clamping.
RGBA parsing and interpolation refinements
bracket-color/src/rgba.rs
Expanded hex parsing rejection tests with additional invalid-length cases and parameterized invalid-character checks, conditional Bevy as_rgba_f32 and channel preservation tests, and updated lerp and lerp_alpha assertions to use exact assert_rgba_eq equality instead of epsilon tolerance.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested labels

size/M

Suggested reviewers

  • utilForever

Poem

🐰 A rabbit hops through tests so bright,
Colors clamped and parsed just right,
From RGB to RGBA's gleam,
Arithmetic flows like a dream!
With lerp so exact, no tolerance jest,
These specs now pass the fullest test! 🎨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'cover RGB and RGBA color APIs' directly and accurately describes the main focus of the pull request—adding comprehensive test coverage for RGB and RGBA color APIs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@DongjaJ DongjaJ changed the title test: cover RGB and RGBA color APIs cover RGB and RGBA color APIs May 15, 2026
@DongjaJ DongjaJ marked this pull request as ready for review May 15, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for RGB and RGBA color APIs

1 participant