Skip to content

Cover RGB and RGBA color APIs#91

Merged
utilForever merged 7 commits into
utilForever:mainfrom
DongjaJ:issue-89-rgb-rgba-color-apis
May 18, 2026
Merged

Cover RGB and RGBA color APIs#91
utilForever merged 7 commits into
utilForever:mainfrom
DongjaJ:issue-89-rgb-rgba-color-apis

Conversation

@DongjaJ

@DongjaJ DongjaJ commented May 15, 2026

Copy link
Copy Markdown
Contributor

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

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
📝 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.
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.
Title check ✅ Passed The title 'Cover RGB and RGBA color APIs' directly and clearly summarizes the main change: adding comprehensive test coverage for RGB and RGBA color APIs.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit 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.

@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
@utilForever utilForever changed the title cover RGB and RGBA color APIs Cover RGB and RGBA color APIs May 18, 2026
@utilForever utilForever self-requested a review May 18, 2026 14:45

@utilForever utilForever left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM. Thanks for your work! 🎉

@utilForever utilForever merged commit 5612251 into utilForever:main May 18, 2026
10 checks passed
@DongjaJ DongjaJ deleted the issue-89-rgb-rgba-color-apis branch May 19, 2026 14:45
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

2 participants