macro_rules! assert_parse {
    ($atomset: path, $ty: ty, $str: literal, $($ast: pat)+) => { ... };
    ($atomset: path, $ty: ty, $str: literal) => { ... };
}Expand description
(Requires feature “testing”) Given a Node, and a string, this will expand to code that sets up a parser, and parses the given string against the given node. If the parse failed this macro will panic with a readable failure. It then writes the result out using crate::CursorWriteSink, writing the parsed Node back out to a string. If resulting string from the given string, then the macro will panic with a readable failure.
use css_parse::*;
assert_parse!(EmptyAtomSet::ATOMS, T![Ident], "foo");For more complex types (for example enum variants), you might want to assert that the given AST node matches an expected pattern (for example, one enum variant was chosen over another). In these cases, passing the match pattern as the third (or fourth) argument will assert that the parsed output struct matches the given pattern:
use css_parse::*;
use csskit_derives::*;
#[derive(Parse, ToCursors, Debug)]
enum IdentOrNumber {
    Ident(T![Ident]),
    Number(T![Number]),
}
assert_parse!(EmptyAtomSet::ATOMS, IdentOrNumber, "foo", IdentOrNumber::Ident(_));
assert_parse!(EmptyAtomSet::ATOMS, IdentOrNumber, "12", IdentOrNumber::Number(_));