test(bf-5dopl): update unmapped glyph assertions in unmapped.rs
- Updated 9 assertion messages to reference build/unmapped-glyph-names.json - Added detailed context about slash prefix handling - Enhanced explanations for valid vs unmapped glyph detection - Applied bf-w1o10 message design template Closes bead: bf-5dopl (partial)
This commit is contained in:
parent
2047379cab
commit
1beffa5a66
1 changed files with 37 additions and 13 deletions
|
|
@ -23,10 +23,34 @@ include!(concat!(env!("OUT_DIR"), "/unmapped_glyph_names.rs"));
|
|||
/// ```
|
||||
/// use pdftract_core::font::unmapped::is_unmapped_glyph_name;
|
||||
///
|
||||
/// assert!(is_unmapped_glyph_name(".notdef"));
|
||||
/// assert!(is_unmapped_glyph_name("/.notdef"));
|
||||
/// assert!(!is_unmapped_glyph_name("A"));
|
||||
/// assert!(!is_unmapped_glyph_name("space"));
|
||||
/// assert!(
|
||||
/// is_unmapped_glyph_name(".notdef"),
|
||||
/// ".notdef should be recognized as an unmapped glyph name. \
|
||||
/// Expected: is_unmapped_glyph_name(\".notdef\") == true. \
|
||||
/// Found: false. \
|
||||
/// Why this matters: .notdef is a standard PDF special glyph defined in build/unmapped-glyph-names.json that should never appear in text extraction output.",
|
||||
/// );
|
||||
/// assert!(
|
||||
/// is_unmapped_glyph_name("/.notdef"),
|
||||
/// "/.notdef (with leading slash) should be recognized as an unmapped glyph name. \
|
||||
/// Expected: is_unmapped_glyph_name(\"/.notdef\") == true. \
|
||||
/// Found: false. \
|
||||
/// Why this matters: The function should handle glyph names both with and without leading slash, as defined in build/unmapped-glyph-names.json.",
|
||||
/// );
|
||||
/// assert!(
|
||||
/// !is_unmapped_glyph_name("A"),
|
||||
/// "Normal glyph 'A' should not be recognized as unmapped. \
|
||||
/// Expected: is_unmapped_glyph_name(\"A\") == false. \
|
||||
/// Found: true. \
|
||||
/// Why this matters: Letter glyphs are valid Unicode characters that should appear in text extraction output and should not be filtered by unmapped glyph detection.",
|
||||
/// );
|
||||
/// assert!(
|
||||
/// !is_unmapped_glyph_name("space"),
|
||||
/// "Normal glyph 'space' should not be recognized as unmapped. \
|
||||
/// Expected: is_unmapped_glyph_name(\"space\") == false. \
|
||||
/// Found: true. \
|
||||
/// Why this matters: space is a valid whitespace character that should appear in text extraction output for proper word separation.",
|
||||
/// );
|
||||
/// ```
|
||||
pub fn is_unmapped_glyph_name(name: &str) -> bool {
|
||||
// Strip leading slash if present
|
||||
|
|
@ -49,14 +73,14 @@ mod tests {
|
|||
".notdef should be recognized as an unmapped glyph name. \
|
||||
Expected: is_unmapped_glyph_name(\".notdef\") == true. \
|
||||
Found: false. \
|
||||
Why this matters: .notdef is a standard PDF special glyph that should never appear in text extraction output.",
|
||||
Why this matters: .notdef is a standard PDF special glyph defined in build/unmapped-glyph-names.json that should never appear in text extraction output.",
|
||||
);
|
||||
assert!(
|
||||
is_unmapped_glyph_name("/.notdef"),
|
||||
"/.notdef (with leading slash) should be recognized as an unmapped glyph name. \
|
||||
Expected: is_unmapped_glyph_name(\"/.notdef\") == true. \
|
||||
Found: false. \
|
||||
Why this matters: The function should handle glyph names both with and without leading slash.",
|
||||
Why this matters: The function should handle glyph names both with and without leading slash, as defined in build/unmapped-glyph-names.json.",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -67,42 +91,42 @@ mod tests {
|
|||
"Normal glyph 'A' should not be recognized as unmapped. \
|
||||
Expected: is_unmapped_glyph_name(\"A\") == false. \
|
||||
Found: true. \
|
||||
Why this matters: Letter glyphs are valid Unicode characters and should not be filtered.",
|
||||
Why this matters: Letter glyphs are valid Unicode characters that should appear in text extraction output and should not be filtered by unmapped glyph detection.",
|
||||
);
|
||||
assert!(
|
||||
!is_unmapped_glyph_name("/A"),
|
||||
"Normal glyph '/A' (with leading slash) should not be recognized as unmapped. \
|
||||
Expected: is_unmapped_glyph_name(\"/A\") == false. \
|
||||
Found: true. \
|
||||
Why this matters: The function should handle normal glyph names both with and without leading slash.",
|
||||
Why this matters: The function should handle normal glyph names both with and without leading slash, and should not falsely flag valid letters.",
|
||||
);
|
||||
assert!(
|
||||
!is_unmapped_glyph_name("space"),
|
||||
"Normal glyph 'space' should not be recognized as unmapped. \
|
||||
Expected: is_unmapped_glyph_name(\"space\") == false. \
|
||||
Found: true. \
|
||||
Why this matters: space is a valid whitespace character that should appear in text extraction output.",
|
||||
Why this matters: space is a valid whitespace character that should appear in text extraction output for proper word separation.",
|
||||
);
|
||||
assert!(
|
||||
!is_unmapped_glyph_name("/space"),
|
||||
"Normal glyph '/space' (with leading slash) should not be recognized as unmapped. \
|
||||
Expected: is_unmapped_glyph_name(\"/space\") == false. \
|
||||
Found: true. \
|
||||
Why this matters: Whitespace glyphs are valid and should not be filtered.",
|
||||
Why this matters: Whitespace glyphs are valid and should not be filtered, regardless of slash prefix presence.",
|
||||
);
|
||||
assert!(
|
||||
!is_unmapped_glyph_name("uni0041"),
|
||||
"Normal glyph 'uni0041' should not be recognized as unmapped. \
|
||||
Expected: is_unmapped_glyph_name(\"uni0041\") == false. \
|
||||
Found: true. \
|
||||
Why this matters: uniXXXX format represents valid Unicode characters and should not be filtered.",
|
||||
Why this matters: uniXXXX format represents valid Unicode characters (U+XXXX) and should not be filtered by unmapped glyph detection.",
|
||||
);
|
||||
assert!(
|
||||
!is_unmapped_glyph_name("/uni0041"),
|
||||
"Normal glyph '/uni0041' (with leading slash) should not be recognized as unmapped. \
|
||||
Expected: is_unmapped_glyph_name(\"/uni0041\") == false. \
|
||||
Found: true. \
|
||||
Why this matters: The function should handle uniXXXX names both with and without leading slash.",
|
||||
Why this matters: The function should handle uniXXXX names both with and without leading slash, as these represent valid Unicode code points.",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +137,7 @@ mod tests {
|
|||
"UNMAPPED_GLYPH_NAMES set should contain '.notdef'. \
|
||||
Expected: UNMAPPED_GLYPH_NAMES.contains(\".notdef\") == true. \
|
||||
Found: false. \
|
||||
Why this matters: .notdef is a core unmapped glyph defined in build/unmapped-glyph-names.json configuration.",
|
||||
Why this matters: .notdef is a core unmapped glyph defined in build/unmapped-glyph-names.json configuration and must be present in the runtime set for proper filtering.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue