Skip to content

Commit

Permalink
[font] update unit test approach to use matches! macro tests on Error…
Browse files Browse the repository at this point in the history
… types
  • Loading branch information
chrissimpkins committed Jul 28, 2021
1 parent a25963b commit b1c17ab
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,7 @@ mod tests {
fn loading_invalid_ufo_dir_path() {
let path = "totally/bogus/filepath/font.ufo";
let font_load_res = Font::load(path);
match font_load_res {
Ok(_) => panic!("unxpected Ok result"),
Err(Error::MissingUfoDir(_)) => (), // expected value
_ => panic!("incorrect error type returned"),
}
assert!(matches!(font_load_res, Err(Error::MissingUfoDir(_))));
}

#[test]
Expand All @@ -462,11 +458,7 @@ mod tests {
// This should raise an error
let path = "testdata/ufo/Tester-MissingMetaInfo.ufo";
let font_load_res = Font::load(path);
match font_load_res {
Ok(_) => panic!("unxpected Ok result"),
Err(Error::MissingFile(_)) => (), // expected value
_ => panic!("incorrect error type returned"),
}
assert!(matches!(font_load_res, Err(Error::MissingFile(_))));
}

#[test]
Expand All @@ -475,11 +467,7 @@ mod tests {
// This should raise an error
let path = "testdata/ufo/Tester-MissingLayerContents.ufo";
let font_load_res = Font::load(path);
match font_load_res {
Ok(_) => panic!("unxpected Ok result"),
Err(Error::MissingFile(_)) => (), // expected value
_ => panic!("incorrect error type returned"),
}
assert!(matches!(font_load_res, Err(Error::MissingFile(_))));
}

#[test]
Expand All @@ -488,11 +476,7 @@ mod tests {
// directory. This should raise an error
let path = "testdata/ufo/Tester-MissingGlyphsContents.ufo";
let font_load_res = Font::load(path);
match font_load_res {
Ok(_) => panic!("unxpected Ok result"),
Err(Error::MissingFile(_)) => (), // expected value
_ => panic!("incorrect error type returned"),
}
assert!(matches!(font_load_res, Err(Error::MissingFile(_))));
}

#[test]
Expand All @@ -501,11 +485,7 @@ mod tests {
// but not in the glyphs.background directory. This should raise an error
let path = "testdata/ufo/Tester-MissingGlyphsContents-BackgroundLayer.ufo";
let font_load_res = Font::load(path);
match font_load_res {
Ok(_) => panic!("unxpected Ok result"),
Err(Error::MissingFile(_)) => (), // expected value
_ => panic!("incorrect error type returned"),
}
assert!(matches!(font_load_res, Err(Error::MissingFile(_))));
}

#[test]
Expand Down

0 comments on commit b1c17ab

Please sign in to comment.