mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add serialize_four_sides, use for serializing BorderRadius
This commit is contained in:
parent
c6feae3c5c
commit
d1e45f78af
5 changed files with 110 additions and 27 deletions
|
@ -4,26 +4,30 @@
|
|||
|
||||
//! Tests for parsing and serialization of values/properties
|
||||
|
||||
use cssparser::Parser;
|
||||
use cssparser::{Parser, ToCss};
|
||||
|
||||
fn parse<T, F: Fn(&mut Parser) -> Result<T, ()>>(f: F, s: &str) -> Result<T, ()> {
|
||||
let mut parser = Parser::new(s);
|
||||
f(&mut parser)
|
||||
}
|
||||
|
||||
fn to_string<T: ToCss>(x: T) -> String {
|
||||
let mut serialized = String::new();
|
||||
x.to_css(&mut serialized).expect("Failed to serialize");
|
||||
serialized
|
||||
}
|
||||
|
||||
// This is a macro so that the file/line information
|
||||
// is preserved in the panic
|
||||
macro_rules! assert_roundtrip {
|
||||
($fun:expr, $input:expr, $output:expr) => {
|
||||
let parsed = $crate::parsing::parse($fun, $input)
|
||||
.expect(&format!("Failed to parse {}", $input));
|
||||
let mut serialized = String::new();
|
||||
::cssparser::ToCss::to_css(&parsed, &mut serialized)
|
||||
.expect("Failed to serialize");
|
||||
let serialized = $crate::parsing::to_string(parsed);
|
||||
assert_eq!(serialized, $output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mod basic_shape;
|
||||
mod position;
|
||||
mod position;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue