Skip to content

Commit 6c75284

Browse files
committed
macro_test
1 parent d459912 commit 6c75284

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

rust/src/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,19 @@ fn mutable_function_argument() {
289289
assert_eq!(a, "abcd");
290290
}
291291

292+
#[test]
293+
fn macro_test() {
294+
macro_rules! sample_macro {
295+
// `()` indicates that the macro takes no argument.
296+
() => { 0 };
297+
($a:expr) => { $a };
298+
($a:expr, $b:expr) => { $a + $b }
299+
}
300+
assert_eq!(sample_macro!(), 0);
301+
assert_eq!(sample_macro!(1), 1);
302+
assert_eq!(sample_macro!(1, 2), 3);
303+
}
304+
292305
#[test]
293306
#[ignore]
294307
fn failing_test() {

0 commit comments

Comments
 (0)