[librsvg: 5/17] Test FitLargestScale with no maximum size
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/17] Test FitLargestScale with no maximum size
- Date: Thu, 24 Feb 2022 03:22:56 +0000 (UTC)
commit d33fd8e97b2e69f2db772b205bb69e764e6157ef
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Feb 21 14:35:39 2022 -0600
Test FitLargestScale with no maximum size
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/669>
src/bin/rsvg-convert.rs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 2610e9ddc..6cfba0230 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -77,6 +77,10 @@ struct Scale {
}
impl Scale {
+ pub fn new(x: f64, y: f64) -> Self {
+ Self { x, y }
+ }
+
#[allow(clippy::float_cmp)]
pub fn is_identity(&self) -> bool {
self.x == 1.0 && self.y == 1.0
@@ -1226,4 +1230,18 @@ mod sizing_tests {
Size::new(50.0, 100.0),
);
}
+
+ #[test]
+ fn fit_largest_scale_no_max_size() {
+ let strategy = ResizeStrategy::FitLargestScale(
+ Scale::new(2.0, 3.0),
+ None,
+ None,
+ );
+
+ assert_eq!(
+ strategy.apply(&Size::new(1.0, 2.0), false).unwrap(),
+ Size::new(2.0, 6.0),
+ );
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]