Skip to content

Instantly share code, notes, and snippets.

@dbousamra
Created April 25, 2019 01:45
Show Gist options
  • Save dbousamra/615199173ccc384b86e64386c1186b69 to your computer and use it in GitHub Desktop.
Save dbousamra/615199173ccc384b86e64386c1186b69 to your computer and use it in GitHub Desktop.
fn main() {
let calc = Calculator;
let add = test_group!(
"Add",
[
test!("Can add 2 and 1", { assert_eq!(2 + 1, 3) }),
test!("Can add -1 and 1", { assert_eq!(-1 + 1, 0) }),
]
);
let subtract = test_group!(
"Subtract",
[
test!("Can subtract 1 from 1", { assert_eq!(1 - 1, 0) }),
test!("Can subtract 2 from 1", { assert_eq!(1 - 2, -1) }),
test!("Can subtract -1 from 1", { assert_eq!(1 - -1, 2) }),
]
);
let multiply = test_group!(
"Multiply",
[
test!("Can multiply 1 and 1", { assert_eq!(1 * 1, 1) }),
test!("Can multiply 2 and 1", { assert_eq!(2 * 1, 2) }),
test!("Can multiply -1 and 1", { assert_eq!(-1 * 1, -1) }),
]
);
let divide = test_group!(
"Divide",
[
test!("Can divide 1 by 1", { assert_eq!(1 / 1, 1) }),
test!("Can divide 2 by 1", { assert_eq!(2 / 1, 2) }),
test!("Can divide -1 by 1", { assert_eq!(-1 / 1, -1) }),
]
);
let suite = test_group!("Calculator", [add, subtract, multiply, divide]);
let test_runner = runners::TestRunner::new();
test_runner.run(&suite);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment