Files
markbase/tests/convert_test.rs
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
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"));
}