Skip to content

Commit 5a36871

Browse files
committed
test: improve test coverage
1 parent 3661c85 commit 5a36871

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

file_type/src/format/file_format.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,36 @@ mod tests {
105105
use super::*;
106106
use crate::format::{ByteSequence, PositionType};
107107

108+
#[test]
108109
fn test_format_id() {
109110
let source_type = SourceType::Custom;
110111
assert_eq!(source_type.format_id(1), "custom/1");
111112
}
112113

114+
#[test]
115+
fn test_priority() {
116+
assert_eq!(SourceType::Custom.priority(), 1);
117+
assert_eq!(SourceType::Default.priority(), 0);
118+
assert_eq!(SourceType::Httpd.priority(), 5);
119+
assert_eq!(SourceType::Linguist.priority(), 4);
120+
assert_eq!(SourceType::Pronom.priority(), 2);
121+
assert_eq!(SourceType::Wikidata.priority(), 3);
122+
}
123+
124+
#[test]
125+
fn test_partial_cmp() {
126+
assert_eq!(SourceType::Custom.partial_cmp(&SourceType::Custom), Some(Ordering::Equal));
127+
assert_eq!(SourceType::Custom.partial_cmp(&SourceType::Default), Some(Ordering::Greater));
128+
assert_eq!(SourceType::Default.partial_cmp(&SourceType::Custom), Some(Ordering::Less));
129+
}
130+
131+
#[test]
132+
fn test_cmp() {
133+
assert_eq!(SourceType::Custom.cmp(&SourceType::Custom), Ordering::Equal);
134+
assert_eq!(SourceType::Custom.cmp(&SourceType::Default), Ordering::Greater);
135+
assert_eq!(SourceType::Default.cmp(&SourceType::Custom), Ordering::Less);
136+
}
137+
113138
#[test]
114139
fn test_to_source() {
115140
let file_format = FileFormat {

0 commit comments

Comments
 (0)