Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/mrml-core/src/helper/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ impl TryFrom<&str> for Pixel {
.parse::<f32>()
.map(Pixel::new)
.map_err(SizeParserError::InvalidFloat)
} else if value == "0" {
Ok(Pixel::new(0.0))
} else {
Err(SizeParserError::MissingSuffix("px"))
}
Expand Down
9 changes: 9 additions & 0 deletions packages/mrml-core/src/helper/spacing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,13 @@ pub mod tests {
let res = Spacing::try_from("2tx 3px 4px 5px");
assert!(res.is_err());
}

#[test]
fn unitless_zero() {
let res: Spacing = Spacing::try_from("20px 20px 0 20px").unwrap();
assert_eq!(res.top(), &Pixel::new(20.0));
assert_eq!(res.right(), &Pixel::new(20.0));
assert_eq!(res.bottom(), &Pixel::new(0.0));
assert_eq!(res.left(), &Pixel::new(20.0));
}
}
Loading