From e30a8ea9850e8b09b93a3a925e1c5d136e8ccbce Mon Sep 17 00:00:00 2001 From: Abitofevrything <54505189+abitofevrything@users.noreply.github.com> Date: Sat, 16 Sep 2023 07:19:52 -0700 Subject: [PATCH] Fix assertion in DiscordColor (#550) --- lib/src/models/discord_color.dart | 2 +- test/unit/models/discord_color_test.dart | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/models/discord_color.dart b/lib/src/models/discord_color.dart index 3d588f69e..f9b2ac12b 100644 --- a/lib/src/models/discord_color.dart +++ b/lib/src/models/discord_color.dart @@ -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. /// diff --git a/test/unit/models/discord_color_test.dart b/test/unit/models/discord_color_test.dart index 523238252..5f4cba7f5 100644 --- a/test/unit/models/discord_color_test.dart +++ b/test/unit/models/discord_color_test.dart @@ -45,5 +45,11 @@ void main() { expect(color, equals(DiscordColor(0xffed12))); }); + + test('max value', () { + final color = DiscordColor(0xffffff); + + expect(color.value, equals(0xffffff)); + }); }); }