[librsvg] gradient: add a test for fix_focus_point



commit a8cd6f616c3069b0d45be089ce856a8e5e74f652
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Sep 8 18:39:24 2018 +0200

    gradient: add a test for fix_focus_point

 rsvg_internals/src/gradient.rs | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index b2892e81..cadf6423 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -725,6 +725,18 @@ mod tests {
         assert!(SpreadMethod::parse_str("foobar", ()).is_err());
     }
 
+    #[test]
+    fn fixes_focus_point() {
+        // inside the circle
+        assert_eq!(fix_focus_point(1.0, 1.0, 2.0, 1.0, 3.0), (1.0, 1.0));
+
+        // on the edge
+        assert_eq!(fix_focus_point(1.0, 1.0, 2.0, 1.0, 2.0), (1.0, 1.0));
+
+        // outside the circle
+        assert_eq!(fix_focus_point(1.0, 1.0, 3.0, 1.0, 1.0), (2.0, 1.0));
+    }
+
     #[test]
     fn gradient_resolved_from_defaults_is_really_resolved() {
         let mut gradient = Gradient {


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