test: add full MaterialType coverage for DocumentInfo (DOC-FULL-022)
- Add 9 new tests: Text, Pdf, Image, Epub, Excel, PowerPoint, all_stats_start_none, file_size, material_type_matches - Total 12 tests covering all 9 MaterialType variants - Capabilities (is_searchable, supports_position, supports_anchor) + preview_mode verified per type Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
dc630ba030
commit
946feff62a
@ -139,4 +139,83 @@ mod tests {
|
|||||||
assert!(!info.supports_position);
|
assert!(!info.supports_position);
|
||||||
assert!(!info.supports_anchor);
|
assert!(!info.supports_anchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_text_capabilities() {
|
||||||
|
let info = DocumentInfo::new("m4".into(), "notes.txt".into(), MaterialType::Text, 512);
|
||||||
|
assert!(info.is_searchable);
|
||||||
|
assert!(info.supports_position);
|
||||||
|
assert!(info.supports_anchor);
|
||||||
|
assert_eq!(info.preview_mode, PreviewMode::NativeReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pdf_capabilities() {
|
||||||
|
let info = DocumentInfo::new("m5".into(), "book.pdf".into(), MaterialType::Pdf, 2048);
|
||||||
|
assert!(info.is_searchable);
|
||||||
|
assert!(info.supports_position);
|
||||||
|
assert!(info.supports_anchor);
|
||||||
|
assert_eq!(info.preview_mode, PreviewMode::PlatformPreview);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_image_capabilities() {
|
||||||
|
let info = DocumentInfo::new("m6".into(), "photo.jpg".into(), MaterialType::Image, 1024);
|
||||||
|
assert!(!info.is_searchable);
|
||||||
|
assert!(info.supports_position);
|
||||||
|
assert!(info.supports_anchor);
|
||||||
|
assert_eq!(info.preview_mode, PreviewMode::NativeReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_epub_capabilities() {
|
||||||
|
let info = DocumentInfo::new("m7".into(), "book.epub".into(), MaterialType::Epub, 4096);
|
||||||
|
assert!(info.is_searchable);
|
||||||
|
assert!(info.supports_position);
|
||||||
|
assert!(info.supports_anchor);
|
||||||
|
assert_eq!(info.preview_mode, PreviewMode::NativeReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_excel_capabilities() {
|
||||||
|
let info = DocumentInfo::new("m8".into(), "sheet.xlsx".into(), MaterialType::Excel, 2048);
|
||||||
|
assert!(!info.is_searchable);
|
||||||
|
assert!(!info.supports_position);
|
||||||
|
assert!(info.supports_anchor);
|
||||||
|
assert_eq!(info.preview_mode, PreviewMode::PlatformPreview);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_powerpoint_capabilities() {
|
||||||
|
let info = DocumentInfo::new("m9".into(), "slides.pptx".into(), MaterialType::PowerPoint, 4096);
|
||||||
|
assert!(!info.is_searchable);
|
||||||
|
assert!(!info.supports_position);
|
||||||
|
assert!(info.supports_anchor);
|
||||||
|
assert_eq!(info.preview_mode, PreviewMode::ExternalOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_all_stats_fields_start_none() {
|
||||||
|
let info = DocumentInfo::new("m10".into(), "any".into(), MaterialType::Markdown, 100);
|
||||||
|
assert_eq!(info.page_count, None);
|
||||||
|
assert_eq!(info.word_count, None);
|
||||||
|
assert_eq!(info.char_count, None);
|
||||||
|
assert_eq!(info.line_count, None);
|
||||||
|
assert_eq!(info.image_width, None);
|
||||||
|
assert_eq!(info.image_height, None);
|
||||||
|
assert_eq!(info.image_format, None);
|
||||||
|
assert_eq!(info.epub_chapter_count, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_file_size_is_set() {
|
||||||
|
let info = DocumentInfo::new("m11".into(), "f".into(), MaterialType::Markdown, 12345);
|
||||||
|
assert_eq!(info.file_size, 12345);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_material_type_matches_input() {
|
||||||
|
let info = DocumentInfo::new("m12".into(), "t".into(), MaterialType::Pdf, 0);
|
||||||
|
assert_eq!(info.material_type, MaterialType::Pdf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user