summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-03-28 13:36:19 +0200
committerGitHub <noreply@github.com>2022-03-28 13:36:19 +0200
commit41d075de5865c8b088c83219431661bc2d1f1802 (patch)
tree13396a172da4ee0cbed234b3ed2f7a141091718f /tests
parent143d13717bcedd00b457958c563f0ab5d7c93896 (diff)
parent1c343cd54d9bdb684de2e793f2ab99bfe85ae0d2 (diff)
Merge pull request #59456 from Calinou/color-expose-to-linear-srgb
Diffstat (limited to 'tests')
-rw-r--r--tests/core/math/test_color.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/core/math/test_color.h b/tests/core/math/test_color.h
index 702f17a9cf..6f40f8ecc0 100644
--- a/tests/core/math/test_color.h
+++ b/tests/core/math/test_color.h
@@ -144,6 +144,24 @@ TEST_CASE("[Color] Conversion methods") {
"The string representation should match the expected value.");
}
+TEST_CASE("[Color] Linear <-> sRGB conversion") {
+ const Color color = Color(0.35, 0.5, 0.6, 0.7);
+ const Color color_linear = color.to_linear();
+ const Color color_srgb = color.to_srgb();
+ CHECK_MESSAGE(
+ color_linear.is_equal_approx(Color(0.100481, 0.214041, 0.318547, 0.7)),
+ "The color converted to linear color space should match the expected value.");
+ CHECK_MESSAGE(
+ color_srgb.is_equal_approx(Color(0.62621, 0.735357, 0.797738, 0.7)),
+ "The color converted to sRGB color space should match the expected value.");
+ CHECK_MESSAGE(
+ color_linear.to_srgb().is_equal_approx(Color(0.35, 0.5, 0.6, 0.7)),
+ "The linear color converted back to sRGB color space should match the expected value.");
+ CHECK_MESSAGE(
+ color_srgb.to_linear().is_equal_approx(Color(0.35, 0.5, 0.6, 0.7)),
+ "The sRGB color converted back to linear color space should match the expected value.");
+}
+
TEST_CASE("[Color] Named colors") {
CHECK_MESSAGE(
Color::named("red").is_equal_approx(Color::hex(0xFF0000FF)),