Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
  • Loading branch information
Licenser committed Jul 18, 2022
1 parent c1f9034 commit a3a3440
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions serial_test_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,55 @@ mod tests {
assert_eq!(format!("{}", compare), format!("{}", stream));
}

#[test]
fn test_serial_with_timeout() {
let attrs = vec![
TokenTree::Ident(format_ident!("timeout_ms")),
TokenTree::Punct(Punct::new('=', Spacing::Alone)),
TokenTree::Literal(Literal::u8_unsuffixed(42)),
];
let input = quote! {
#[test]
fn foo() {}
};
let stream = local_serial_core(
proc_macro2::TokenStream::from_iter(attrs.into_iter()),
input,
);
let compare = quote! {
#[test]
fn foo () {
serial_test::local_serial_core("", :: std :: option :: Option :: Some (42u64), || {} );
}
};
assert_eq!(format!("{}", compare), format!("{}", stream));
}

#[test]
fn test_serial_with_name_and_timeout() {
let attrs = vec![
TokenTree::Ident(format_ident!("foo")),
TokenTree::Punct(Punct::new(',', Spacing::Alone)),
TokenTree::Ident(format_ident!("timeout_ms")),
TokenTree::Punct(Punct::new('=', Spacing::Alone)),
TokenTree::Literal(Literal::u8_unsuffixed(42)),
];
let input = quote! {
#[test]
fn foo() {}
};
let stream = local_serial_core(
proc_macro2::TokenStream::from_iter(attrs.into_iter()),
input,
);
let compare = quote! {
#[test]
fn foo () {
serial_test::local_serial_core("foo", :: std :: option :: Option :: Some (42u64), || {} );
}
};
assert_eq!(format!("{}", compare), format!("{}", stream));
}
#[test]
fn test_stripped_attributes() {
let _ = env_logger::builder().is_test(true).try_init();
Expand Down

0 comments on commit a3a3440

Please sign in to comment.