// Copyright 2015 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 or the MIT license
// , at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(plugin)]
#![plugin(string_cache_plugin)]
extern crate string_cache;
extern crate tendril;
extern crate html5ever;
extern crate html5ever_dom_sink;
use std::default::Default;
use tendril::{StrTendril, SliceExt};
use html5ever::driver::ParseOpts;
use html5ever::{parse_fragment, parse, one_input, serialize};
use html5ever_dom_sink::rcdom::RcDom;
fn parse_and_serialize(input: StrTendril) -> StrTendril {
let dom: RcDom = parse_fragment(one_input(input), atom!(body), ParseOpts::default());
let inner = &dom.document.borrow().children[0];
let mut result = vec![];
serialize(&mut result, inner, Default::default()).unwrap();
StrTendril::try_from_byte_slice(&result).unwrap()
}
macro_rules! test {
($name:ident, $input:expr, $output:expr) => {
#[test]
fn $name() {
assert_eq!($output, &*parse_and_serialize($input.to_tendril()));
}
};
// Shorthand for $output = $input
($name:ident, $input:expr) => {
test!($name, $input, $input);
};
}
test!(empty, r#""#);
test!(smoke_test, r#"