1 // Macros for use in writing tests generic over &str/&[u8].
2 macro_rules
! text { ($text:expr) => { $text }
}
3 macro_rules
! t { ($text:expr) => { text!($text) }
}
4 macro_rules
! match_text { ($text:expr) => { $text.as_str() }
}
6 macro_rules
! no_expand
{
13 macro_rules
! show { ($text:expr) => { $text }
}
15 // N.B. The expansion API for &str and &[u8] APIs differs slightly for now,
16 // but they should be unified in 1.0. Then we can move this macro back into
17 // tests/api.rs where it is used. ---AG
19 ($name
:ident
, $re
:expr
, $text
:expr
, $expand
:expr
, $expected
:expr
) => {
23 let cap
= re
.captures(t
!($text
)).unwrap();
25 let mut got
= String
::new();
26 cap
.expand(t
!($expand
), &mut got
);
27 assert_eq
!(show
!(t
!($expected
)), show
!(&*got
));
32 #[cfg(feature = "pattern")]
33 macro_rules
! searcher_expr { ($e:expr) => ($e) }
34 #[cfg(not(feature = "pattern"))]
35 macro_rules
! searcher_expr { ($e:expr) => ({}
) }