Add serialize_four_sides, use for serializing BorderRadius

This commit is contained in:
Manish Goregaokar 2016-08-02 15:43:52 +05:30
parent c6feae3c5c
commit d1e45f78af
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
5 changed files with 110 additions and 27 deletions

View file

@ -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;