Skip to content

Commit

Permalink
Fix assertion in DiscordColor (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
abitofevrything authored Sep 16, 2023
1 parent bfbe4e5 commit e30a8ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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));
});
});
}

0 comments on commit e30a8ea

Please sign in to comment.