diff options
Diffstat (limited to 'tests/unit/style/parsing/basic_shape.rs')
-rw-r--r-- | tests/unit/style/parsing/basic_shape.rs | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/tests/unit/style/parsing/basic_shape.rs b/tests/unit/style/parsing/basic_shape.rs index 0f8f6f4ccb5..dbe1c209baf 100644 --- a/tests/unit/style/parsing/basic_shape.rs +++ b/tests/unit/style/parsing/basic_shape.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use parsing::parse; +use parsing::{parse, to_string}; use style::values::specified::basic_shape::*; // Ensure that basic-shape sub-functions parse as both basic shapes @@ -14,6 +14,23 @@ macro_rules! assert_roundtrip_basicshape { } } +macro_rules! assert_border_radius_values { + ($input:expr; $tlw:expr, $trw:expr, $blw:expr, $brw:expr ; + $tlh:expr, $trh:expr, $blh:expr, $brh:expr) => { + let input = parse(BorderRadius::parse, $input) + .expect(&format!("Failed parsing {} as border radius", + $input)); + assert_eq!(to_string(input.top_left.0.width), $tlw); + assert_eq!(to_string(input.top_right.0.width), $trw); + assert_eq!(to_string(input.bottom_left.0.width), $blw); + assert_eq!(to_string(input.bottom_right.0.width), $brw); + assert_eq!(to_string(input.top_left.0.height), $tlh); + assert_eq!(to_string(input.top_right.0.height), $trh); + assert_eq!(to_string(input.bottom_left.0.height), $blh); + assert_eq!(to_string(input.bottom_right.0.height), $brh); + } +} + #[test] fn test_inset() { // these are actually wrong, we should be serializing to the minimum possible result @@ -23,11 +40,9 @@ fn test_inset() { assert_roundtrip_basicshape!(InsetRect::parse, "inset(10px 20%)", "inset(10px 20% 10px 20%)"); assert_roundtrip_basicshape!(InsetRect::parse, "inset(10px round 10px)", - "inset(10px 10px 10px 10px round 10px 10px 10px 10px \ - / 10px 10px 10px 10px)"); + "inset(10px 10px 10px 10px round 10px)"); assert_roundtrip_basicshape!(InsetRect::parse, "inset(10px round 10px 20px 30px 40px)", - "inset(10px 10px 10px 10px round 10px 20px 30px 40px \ - / 10px 20px 30px 40px)"); + "inset(10px 10px 10px 10px round 10px 20px 30px 40px)"); assert_roundtrip_basicshape!(InsetRect::parse, "inset(10px 10px 10px 10px round 10px 20px 30px 40px \ / 1px 2px 3px 4px)", "inset(10px 10px 10px 10px round 10px 20px 30px 40px \ @@ -35,6 +50,31 @@ fn test_inset() { } #[test] +fn test_border_radius() { + assert_border_radius_values!("10px"; + "10px", "10px", "10px", "10px" ; + "10px", "10px", "10px", "10px"); + assert_border_radius_values!("10px 20px"; + "10px", "20px", "10px", "20px" ; + "10px", "20px", "10px", "20px"); + assert_border_radius_values!("10px 20px 30px"; + "10px", "20px", "30px", "20px" ; + "10px", "20px", "30px", "20px"); + assert_border_radius_values!("10px 20px 30px 40px"; + "10px", "20px", "30px", "40px" ; + "10px", "20px", "30px", "40px"); + assert_border_radius_values!("10% / 20px"; + "10%", "10%", "10%", "10%" ; + "20px", "20px", "20px", "20px"); + assert_border_radius_values!("10px / 20px 30px"; + "10px", "10px", "10px", "10px" ; + "20px", "30px", "20px", "30px"); + assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px"; + "10px", "20px", "30px", "40px" ; + "1px", "2px", "3px", "4px"); +} + +#[test] fn test_circle() { assert_roundtrip_basicshape!(Circle::parse, "circle(at center)", "circle(at 50% 50%)"); assert_roundtrip_basicshape!(Circle::parse, "circle()", "circle(at 50% 50%)"); |