Skip to content

Conversation

@chrivers
Copy link
Owner

Add unit test coverage for almost all lines of code in the hue crate, that is not a data model or constructor.

This work is a bit tedious, but very exciting for the maintainability of Bifrost.

The hue crate contains a significant amount of code related to handling events, colors, colorspaces, gamma correction, etc.

All of this code is now tested against our assumptions of what it should do.
This obviously doesn't test if our assumptions are correct, but at least now
the code can't easily deviate from them.

Adding these unit tests uncovered a number of minor errors that have been fixed:

  • Fix HueEntSegmentLayout::pack(), which produced wrong output (currently not used in Bifrost)
  • Make HueStreamPacket::parse() not panic on invalid input
  • Make Clamp::unit_to_u8_clamped() perform proper rounding.
  • Make XY::from_rgb_unit() fall back to D50_WHITE_POINT, not D65_WHITE_POINT.

Overall, these are minor papercuts that have not noticeably affected the functionality of Bifrost. Nevertheless, it is nice to have good test coverage.

chrivers added 30 commits May 24, 2025 10:47
…und rounding errrors, it could otherwise go slightly beyond this limit.
@chrivers chrivers merged commit 70895fc into master May 24, 2025
1 check passed
@chrivers chrivers deleted the chrivers/unit-test-improvements branch May 24, 2025 09:04
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.

2 participants