Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 17, 2018 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/a983d9e6cae019d8a4f3abc643a2e00d to your computer and use it in GitHub Desktop.
Save rust-play/a983d9e6cae019d8a4f3abc643a2e00d to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
macro_rules! t {
($(#[$attr:meta])* $name:ident($pattern:expr, [$($file:expr),*])) => {
$(#[$attr])*
fn $name() {
let pattern = $pattern;
let files = vec![$(concat!(stringify!($name),"_",$file)),*];
process_grep_case(pattern, &files);
panic!("we want to see the output")
}
}
}
fn process_grep_case(pattern: &str, files: &[&str]) {
println!("Pattern: {}", pattern);
println!("Files: {:?}", files)
}
t!(#[test]
test_grep_returns_result(
"Agamemnon",
["iliad.txt", "paradise_lost.txt"]
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment