Created
July 17, 2018 20:48
-
-
Save rust-play/a983d9e6cae019d8a4f3abc643a2e00d to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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