From 1beffa5a66ad7a36f0a010ecee681db3cc6e4933 Mon Sep 17 00:00:00 2001 From: jedarden Date: Mon, 6 Jul 2026 20:42:17 -0400 Subject: [PATCH] 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) --- crates/pdftract-core/src/font/unmapped.rs | 50 +++++++++++++++++------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/crates/pdftract-core/src/font/unmapped.rs b/crates/pdftract-core/src/font/unmapped.rs index d94973e..aefaefd 100644 --- a/crates/pdftract-core/src/font/unmapped.rs +++ b/crates/pdftract-core/src/font/unmapped.rs @@ -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.", ); } }