Skip to content

Commit

Permalink
add test and docs for Type::metcher_type()
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Jul 19, 2021
1 parent 9c6da0d commit 3eccccb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let kind = infer::get(&buf).expect("file type is known");
assert_eq!(kind.mime_type(), "image/jpeg");
assert_eq!(kind.extension(), "jpg");
assert_eq!(kind.matcher_type(), infer::MatcherType::Image);
```
### Check file type by path
Expand Down Expand Up @@ -129,6 +130,16 @@ impl Type {
}

/// Returns the type of matcher
///
/// # Examples
///
/// ```rust
/// let info = infer::Infer::new();
/// let buf = [0xFF, 0xD8, 0xFF, 0xAA];
/// let kind = info.get(&buf).expect("file type is known");
///
/// assert_eq!(kind.matcher_type(), infer::MatcherType::Image);
/// ```
pub const fn matcher_type(&self) -> MatcherType {
self.matcher_type
}
Expand Down Expand Up @@ -613,6 +624,13 @@ mod tests {
assert_eq!(kind.mime_type(), "image/jpeg");
}

#[test]
fn test_matcher_type() {
let buf = [0xFF, 0xD8, 0xFF, 0xAA];
let kind = crate::get(&buf).expect("file type is known");
assert_eq!(kind.matcher_type(), crate::MatcherType::Image);
}

#[cfg(feature = "alloc")]
#[test]
fn test_custom_matcher_ordering() {
Expand Down

0 comments on commit 3eccccb

Please sign in to comment.