()
| 267 | |
| 268 | #[test] |
| 269 | fn test_multibyte_character_counting() { |
| 270 | let validator = StringConstraintValidator::new(); |
| 271 | let conn = setup_test_db(); |
| 272 | |
| 273 | // Add a constraint |
| 274 | conn.execute( |
| 275 | "INSERT INTO __pgsqlite_string_constraints (table_name, column_name, max_length, is_char_type) |
| 276 | VALUES ('test', 'text', 3, 0)", |
| 277 | [], |
| 278 | ).unwrap(); |
| 279 | |
| 280 | // Load constraints |
| 281 | validator.load_table_constraints(&conn, "test").unwrap(); |
| 282 | |
| 283 | // Test with multi-byte characters |
| 284 | assert!(validator.validate_value("test", "text", "你好世").is_ok()); // 3 characters |
| 285 | assert!(validator.validate_value("test", "text", "你好世界").is_err()); // 4 characters |
| 286 | assert!(validator.validate_value("test", "text", "😀😀😀").is_ok()); // 3 emojis |
| 287 | assert!(validator.validate_value("test", "text", "café").is_err()); // 4 characters |
| 288 | } |
| 289 | |
| 290 | #[test] |
| 291 | fn test_char_padding() { |
nothing calls this directly
no test coverage detected