Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add tests for the various parsers and cover edge cases #947

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

lbrooks
Copy link
Contributor

@lbrooks lbrooks commented Nov 15, 2024

List of updates to the method:

  • Sanitize numbers to ensure within [0-255]
    • When called with isRgbw == false, numbers outside of [0-255[ could make it into the PaletteType[] returned
  • When there aren't enough values to complete the last color, fill the missing values with 0s
    • In the previous code, the value would contain NaN
  • Simplify logic
    • Switched from a reducer needing state to a simple for loop
  • Add tests to cover all edge cases

* Sanitize numbers to ensure within [0-255]
* Gracefully handle incorrect number of values
* Simplify logic
* Add tests to cover all edge cases

Signed-off-by: Lawrence Brooks <[email protected]>
Signed-off-by: Lawrence Brooks <[email protected]>
@lbrooks lbrooks marked this pull request as ready for review November 15, 2024 05:14
@lbrooks lbrooks changed the title fix: Add tests for parsePaletteRaw, cover edge cases fix: Add tests for colormap, keymap, palette, superkey parsers and cover edge cases Nov 15, 2024
@lbrooks lbrooks changed the title fix: Add tests for colormap, keymap, palette, superkey parsers and cover edge cases fix: Add tests for the various parsers and cover edge cases Nov 15, 2024
lbrooks and others added 2 commits November 22, 2024 09:12
* colormap values are [0-palette_length)
   * palette_length is undefined, just ensure [0
* keymap values are [0-??), just ensure [0
* palette values are [0-255], ensure [0-255]

Signed-off-by: Lawrence Brooks <[email protected]>
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