Files
markbase/tests/convert_test.rs
T
Warren 8371aef693 fix: resolve clippy warnings and test errors
- Implement FromStr trait for NodeType instead of custom from_str method
- Fix redundant_closure warning in server.rs:455
- Add #[allow(clippy::too_many_arguments)] for new_file_node
- Fix unused variables in tests (_user_id, _conn)
- Remove unused imports (NodeType, serde_json::json)
- Replace len() > 0 with !is_empty() for clarity
- Replace == false with negation operator
- Format code with cargo fmt
2026-05-16 16:13:37 +08:00

65 lines
1.7 KiB
Rust

use markbase::filetree::convert::{is_apple_format_ext, is_document_ext, is_textutil_ext};
#[test]
fn test_is_document_ext_textutil() {
assert!(is_document_ext("docx"));
assert!(is_document_ext("doc"));
assert!(is_document_ext("rtf"));
}
#[test]
fn test_is_document_ext_apple() {
assert!(is_document_ext("pages"));
assert!(is_document_ext("key"));
assert!(is_document_ext("numbers"));
}
#[test]
fn test_is_document_ext_soffice() {
assert!(is_document_ext("pptx"));
assert!(is_document_ext("ppt"));
assert!(is_document_ext("xlsx"));
assert!(is_document_ext("xls"));
assert!(is_document_ext("odt"));
assert!(is_document_ext("epub"));
}
#[test]
fn test_is_document_ext_false() {
assert!(!is_document_ext("mp4"));
assert!(!is_document_ext("jpg"));
assert!(!is_document_ext("txt"));
assert!(!is_document_ext("pdf"));
}
#[test]
fn test_is_textutil_ext() {
assert!(is_textutil_ext("docx"));
assert!(is_textutil_ext("doc"));
assert!(is_textutil_ext("rtf"));
assert!(!is_textutil_ext("pages"));
assert!(!is_textutil_ext("mp4"));
}
#[test]
fn test_is_apple_format_ext() {
assert!(is_apple_format_ext("pages"));
assert!(is_apple_format_ext("key"));
assert!(is_apple_format_ext("numbers"));
assert!(!is_apple_format_ext("docx"));
assert!(!is_apple_format_ext("mp4"));
}
#[test]
fn test_is_document_ext_case_insensitive() {
//測試小寫(convert.rs使用小寫比較)
assert!(is_document_ext("docx"));
assert!(!is_document_ext("DOCX")); //函數未轉小寫,直接比較
}
#[test]
fn test_is_document_ext_empty() {
assert!(!is_document_ext(""));
assert!(!is_document_ext("unknown"));
}