[librsvg: 14/22] Add a couple of tests for the font shorthand parser



commit da0558cb45e8b98890d0d56a079b370b43523941
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jun 30 15:14:45 2020 -0500

    Add a couple of tests for the font shorthand parser

 rsvg_internals/src/font_props.rs | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/rsvg_internals/src/font_props.rs b/rsvg_internals/src/font_props.rs
index ac4ae37c..61d9835a 100644
--- a/rsvg_internals/src/font_props.rs
+++ b/rsvg_internals/src/font_props.rs
@@ -469,6 +469,40 @@ mod tests {
 
     use crate::properties::{ParsedProperty, SpecifiedValue, SpecifiedValues};
 
+    #[test]
+    fn parses_font_shorthand() {
+        assert_eq!(
+            Font::parse_str("small-caption").unwrap(),
+            Font::SmallCaption,
+        );
+
+        assert_eq!(
+            Font::parse_str("italic bold 12px sans").unwrap(),
+            Font::Spec {
+                style: FontStyle::Italic,
+                variant: Default::default(),
+                weight: FontWeight::Bold,
+                stretch: Default::default(),
+                size: FontSize::Value(Length::new(12.0, LengthUnit::Px)),
+                line_height: Default::default(),
+                family: FontFamily("sans".to_string()),
+            },
+        );
+
+        assert_eq!(
+            Font::parse_str("bold 14cm/2 serif").unwrap(),
+            Font::Spec {
+                style: Default::default(),
+                variant: Default::default(),
+                weight: FontWeight::Bold,
+                stretch: Default::default(),
+                size: FontSize::Value(Length::new(14.0, LengthUnit::Cm)),
+                line_height: LineHeight::Number(2.0),
+                family: FontFamily("serif".to_string()),
+            },
+        );
+    }
+
     #[test]
     fn detects_invalid_invalid_font_size() {
         assert!(FontSize::parse_str("furlong").is_err());


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