[librsvg: 4/17] Tests for fitting to width and height




commit bd3001f947e0878c2db21403320d473028bbda68
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Feb 21 12:39:31 2022 -0600

    Tests for fitting to width and height
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/669>

 src/bin/rsvg-convert.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 219daab32..2610e9ddc 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -1206,4 +1206,24 @@ mod sizing_tests {
             Size::new(25.0, 50.0),
         );
     }
+
+    #[test]
+    fn fit_width() {
+        let strategy = ResizeStrategy::FitWidth(100.0);
+
+        assert_eq!(
+            strategy.apply(&Size::new(1.0, 2.0), false).unwrap(),
+            Size::new(100.0, 200.0),
+        );
+    }
+
+    #[test]
+    fn fit_height() {
+        let strategy = ResizeStrategy::FitHeight(100.0);
+
+        assert_eq!(
+            strategy.apply(&Size::new(1.0, 2.0), false).unwrap(),
+            Size::new(50.0, 100.0),
+        );
+    }
 }


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