From 9cb64dd8a7d5455fd20e53b3c7c5a07509965ca8 Mon Sep 17 00:00:00 2001 From: Zaki Date: Thu, 26 Mar 2026 16:56:56 -0700 Subject: [PATCH] fix: clarify test comment and use exact assertions Address Gemini review feedback: - Fix misleading comment: \u{00e9} is precomposed e-acute, not combining accent - Replace weak assertions (ends_with/is_empty) with exact assert_eq! Co-Authored-By: Claude Opus 4.6 (1M context) --- src/cli/memory.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cli/memory.rs b/src/cli/memory.rs index 4c04fd2c..fca6d03b 100644 --- a/src/cli/memory.rs +++ b/src/cli/memory.rs @@ -296,16 +296,14 @@ mod tests { #[test] fn test_truncate_content_multibyte_does_not_panic() { - // "cafe\u{0301}" = "café" where é is e + combining accent (2 bytes for accent) - // Slicing at byte 5 would land inside the combining character - let s = "caf\u{00e9} au lait"; // café = 5 bytes (é is 2 bytes) - let result = truncate_content(s, 4); // byte 4 is inside é - assert!(result.ends_with("...")); - assert!(!result.is_empty()); + // \u{00e9} is precomposed 'é' (2 bytes in UTF-8) + let s = "caf\u{00e9} au lait"; // "café au lait", é starts at byte 3 + let result = truncate_content(s, 4); // byte 4 is inside 2-byte é + assert_eq!(result, "caf..."); // 4-byte emoji: slicing mid-emoji must not panic - let emoji = "Hi \u{1F600} there"; // 😀 is 4 bytes + let emoji = "Hi \u{1F600} there"; // 😀 is 4 bytes, starts at byte 3 let result = truncate_content(emoji, 4); // byte 4 is inside 😀 - assert!(result.ends_with("...")); + assert_eq!(result, "Hi ..."); } }