[librsvg: 15/17] Add tests for the missing cases
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 15/17] Add tests for the missing cases
- Date: Thu, 24 Feb 2022 03:22:56 +0000 (UTC)
commit 7b725e16703f7fc1fde24e02d519172295d85da3
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Feb 23 18:59:36 2022 -0600
Add tests for the missing cases
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/669>
src/bin/rsvg-convert.rs | 77 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 1 deletion(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 4f2547f7a..0d305d664 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -1306,7 +1306,7 @@ mod sizing_tests {
}
#[test]
- fn scale_with_max_size_fits() {
+ fn scale_with_max_width_and_height_fits_non_proportional() {
let strategy = ResizeStrategy::ScaleWithMaxSize {
scale: Scale { x: 2.0, y: 3.0 },
max_width: Some(10.0),
@@ -1320,6 +1320,21 @@ mod sizing_tests {
);
}
+ #[test]
+ fn scale_with_max_width_and_height_fits_proportional() {
+ let strategy = ResizeStrategy::ScaleWithMaxSize {
+ scale: Scale { x: 2.0, y: 3.0 },
+ max_width: Some(10.0),
+ max_height: Some(20.0),
+ keep_aspect_ratio: true,
+ };
+
+ assert_eq!(
+ strategy.apply(&Size::new(4.0, 2.0)).unwrap(),
+ Size::new(8.0, 6.0)
+ );
+ }
+
#[test]
fn scale_with_max_width_and_height_doesnt_fit_non_proportional() {
let strategy = ResizeStrategy::ScaleWithMaxSize {
@@ -1352,6 +1367,66 @@ mod sizing_tests {
);
}
+ #[test]
+ fn scale_with_max_width_fits_non_proportional() {
+ let strategy = ResizeStrategy::ScaleWithMaxSize {
+ scale: Scale { x: 5.0, y: 20.0 },
+ max_width: Some(10.0),
+ max_height: None,
+ keep_aspect_ratio: false,
+ };
+
+ assert_eq!(
+ strategy.apply(&Size::new(1.0, 10.0)).unwrap(),
+ Size::new(5.0, 200.0),
+ );
+ }
+
+ #[test]
+ fn scale_with_max_width_fits_proportional() {
+ let strategy = ResizeStrategy::ScaleWithMaxSize {
+ scale: Scale { x: 5.0, y: 20.0 },
+ max_width: Some(10.0),
+ max_height: None,
+ keep_aspect_ratio: true,
+ };
+
+ assert_eq!(
+ strategy.apply(&Size::new(1.0, 10.0)).unwrap(),
+ Size::new(5.0, 200.0),
+ );
+ }
+
+ #[test]
+ fn scale_with_max_height_fits_non_proportional() {
+ let strategy = ResizeStrategy::ScaleWithMaxSize {
+ scale: Scale { x: 20.0, y: 5.0 },
+ max_width: None,
+ max_height: Some(10.0),
+ keep_aspect_ratio: false,
+ };
+
+ assert_eq!(
+ strategy.apply(&Size::new(10.0, 1.0)).unwrap(),
+ Size::new(200.0, 5.0),
+ );
+ }
+
+ #[test]
+ fn scale_with_max_height_fits_proportional() {
+ let strategy = ResizeStrategy::ScaleWithMaxSize {
+ scale: Scale { x: 20.0, y: 5.0 },
+ max_width: None,
+ max_height: Some(10.0),
+ keep_aspect_ratio: true,
+ };
+
+ assert_eq!(
+ strategy.apply(&Size::new(10.0, 1.0)).unwrap(),
+ Size::new(200.0, 5.0),
+ );
+ }
+
#[test]
fn scale_with_max_width_doesnt_fit_non_proportional() {
let strategy = ResizeStrategy::ScaleWithMaxSize {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]