[librsvg: 19/27] Add tests for resolve_color




commit 6b53a3be631ef1e16f2a0552d46c2f0a3d67e162
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Mar 5 14:06:57 2021 -0600

    Add tests for resolve_color

 src/paint_server.rs | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/src/paint_server.rs b/src/paint_server.rs
index 01604ffd..3895608b 100644
--- a/src/paint_server.rs
+++ b/src/paint_server.rs
@@ -297,4 +297,32 @@ mod tests {
 
         assert!(PaintServer::parse_str("url(#link) invalid").is_err());
     }
+
+    #[test]
+    fn resolves_explicit_color() {
+        use cssparser::{Color, RGBA};
+
+        assert_eq!(
+            resolve_color(
+                &Color::RGBA(RGBA::new(255, 0, 0, 128)),
+                UnitInterval::clamp(0.5),
+                RGBA::new(0, 255, 0, 255)
+            ),
+            RGBA::new(255, 0, 0, 64),
+        );
+    }
+
+    #[test]
+    fn resolves_current_color() {
+        use cssparser::{Color, RGBA};
+
+        assert_eq!(
+            resolve_color(
+                &Color::CurrentColor,
+                UnitInterval::clamp(0.5),
+                RGBA::new(0, 255, 0, 128)
+            ),
+            RGBA::new(0, 255, 0, 64),
+        );
+    }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]