Skip to content

Commit

Permalink
Merge pull request xd009642#348 from shnewto/matches-test-scenario
Browse files Browse the repository at this point in the history
Add match expr test and run in test suite
  • Loading branch information
xd009642 authored Feb 17, 2020
2 parents 810607e + 3fa055b commit 6f610c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/data/matches/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
pub enum LibType {
A(usize),
B(usize),
}

pub fn check_libtype_match(lt: LibType) -> usize {
match lt {
LibType::A(n) => n,
LibType::B(n) => n,
}
}

pub fn check_match(x: usize) -> usize {
match x {
Expand All @@ -16,7 +27,6 @@ pub fn destructuring_match(x: u32, y: u32) {
(2, 2) => 2,
_ => 0,
};

}

#[cfg(test)]
Expand All @@ -25,6 +35,9 @@ mod tests {

#[test]
fn it_works() {
check_libtype_match(LibType::A(0));
check_libtype_match(LibType::B(1));

check_match(0);
check_match(2);
check_match(999999);
Expand Down
5 changes: 5 additions & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ fn method_calls_expr_coverage() {
check_percentage("method_calls", 1.0f64, true);
}

#[test]
fn match_expr_coverage() {
check_percentage("matches", 1.0f64, true);
}

#[test]
#[ignore]
fn benchmark_coverage() {
Expand Down

0 comments on commit 6f610c5

Please sign in to comment.