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:
jedarden 2026-07-06 20:42:17 -04:00
parent 2047379cab
commit 1beffa5a66

View file

@ -23,10 +23,34 @@ include!(concat!(env!("OUT_DIR"), "/unmapped_glyph_names.rs"));
/// ``` /// ```
/// use pdftract_core::font::unmapped::is_unmapped_glyph_name; /// use pdftract_core::font::unmapped::is_unmapped_glyph_name;
/// ///
/// assert!(is_unmapped_glyph_name(".notdef")); /// assert!(
/// assert!(is_unmapped_glyph_name("/.notdef")); /// is_unmapped_glyph_name(".notdef"),
/// assert!(!is_unmapped_glyph_name("A")); /// ".notdef should be recognized as an unmapped glyph name. \
/// assert!(!is_unmapped_glyph_name("space")); /// 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 { pub fn is_unmapped_glyph_name(name: &str) -> bool {
// Strip leading slash if present // Strip leading slash if present
@ -49,14 +73,14 @@ mod tests {
".notdef should be recognized as an unmapped glyph name. \ ".notdef should be recognized as an unmapped glyph name. \
Expected: is_unmapped_glyph_name(\".notdef\") == true. \ Expected: is_unmapped_glyph_name(\".notdef\") == true. \
Found: false. \ 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!( assert!(
is_unmapped_glyph_name("/.notdef"), is_unmapped_glyph_name("/.notdef"),
"/.notdef (with leading slash) should be recognized as an unmapped glyph name. \ "/.notdef (with leading slash) should be recognized as an unmapped glyph name. \
Expected: is_unmapped_glyph_name(\"/.notdef\") == true. \ Expected: is_unmapped_glyph_name(\"/.notdef\") == true. \
Found: false. \ 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. \ "Normal glyph 'A' should not be recognized as unmapped. \
Expected: is_unmapped_glyph_name(\"A\") == false. \ Expected: is_unmapped_glyph_name(\"A\") == false. \
Found: true. \ 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!( assert!(
!is_unmapped_glyph_name("/A"), !is_unmapped_glyph_name("/A"),
"Normal glyph '/A' (with leading slash) should not be recognized as unmapped. \ "Normal glyph '/A' (with leading slash) should not be recognized as unmapped. \
Expected: is_unmapped_glyph_name(\"/A\") == false. \ Expected: is_unmapped_glyph_name(\"/A\") == false. \
Found: true. \ 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!( assert!(
!is_unmapped_glyph_name("space"), !is_unmapped_glyph_name("space"),
"Normal glyph 'space' should not be recognized as unmapped. \ "Normal glyph 'space' should not be recognized as unmapped. \
Expected: is_unmapped_glyph_name(\"space\") == false. \ Expected: is_unmapped_glyph_name(\"space\") == false. \
Found: true. \ 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!( assert!(
!is_unmapped_glyph_name("/space"), !is_unmapped_glyph_name("/space"),
"Normal glyph '/space' (with leading slash) should not be recognized as unmapped. \ "Normal glyph '/space' (with leading slash) should not be recognized as unmapped. \
Expected: is_unmapped_glyph_name(\"/space\") == false. \ Expected: is_unmapped_glyph_name(\"/space\") == false. \
Found: true. \ 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!( assert!(
!is_unmapped_glyph_name("uni0041"), !is_unmapped_glyph_name("uni0041"),
"Normal glyph 'uni0041' should not be recognized as unmapped. \ "Normal glyph 'uni0041' should not be recognized as unmapped. \
Expected: is_unmapped_glyph_name(\"uni0041\") == false. \ Expected: is_unmapped_glyph_name(\"uni0041\") == false. \
Found: true. \ 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!( assert!(
!is_unmapped_glyph_name("/uni0041"), !is_unmapped_glyph_name("/uni0041"),
"Normal glyph '/uni0041' (with leading slash) should not be recognized as unmapped. \ "Normal glyph '/uni0041' (with leading slash) should not be recognized as unmapped. \
Expected: is_unmapped_glyph_name(\"/uni0041\") == false. \ Expected: is_unmapped_glyph_name(\"/uni0041\") == false. \
Found: true. \ 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'. \ "UNMAPPED_GLYPH_NAMES set should contain '.notdef'. \
Expected: UNMAPPED_GLYPH_NAMES.contains(\".notdef\") == true. \ Expected: UNMAPPED_GLYPH_NAMES.contains(\".notdef\") == true. \
Found: false. \ 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.",
); );
} }
} }