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 assertion in DiscordColor #550

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/models/discord_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DiscordColor {
int get b => value & 0xff;

/// Create a [DiscordColor] from a 24 bit encoded [value].
const DiscordColor(this.value) : assert(value >= 0 && value < 0xffffff, 'value must be between 0 and ${0xffffff}');
const DiscordColor(this.value) : assert(value >= 0 && value <= 0xffffff, 'value must be between 0 and ${0xffffff}');

/// Create a [DiscordColor] from [r], [g] and [b] channels ranging from 0 to 255 combined.
///
Expand Down
6 changes: 6 additions & 0 deletions test/unit/models/discord_color_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,11 @@ void main() {

expect(color, equals(DiscordColor(0xffed12)));
});

test('max value', () {
final color = DiscordColor(0xffffff);

expect(color.value, equals(0xffffff));
});
});
}
Loading