()
| 328 | |
| 329 | #[test] |
| 330 | fn test_pattern_validation_edge_cases() { |
| 331 | let edge_cases = [ |
| 332 | ( |
| 333 | "empty pattern should always succeed", |
| 334 | "anything", |
| 335 | None, |
| 336 | true, |
| 337 | ), |
| 338 | ( |
| 339 | "empty string with non-empty pattern should fail", |
| 340 | "", |
| 341 | Some("^.+$"), |
| 342 | false, |
| 343 | ), |
| 344 | ( |
| 345 | "empty string with empty pattern should succeed", |
| 346 | "", |
| 347 | Some("^$"), |
| 348 | true, |
| 349 | ), |
| 350 | ( |
| 351 | "whitespace with whitespace pattern", |
| 352 | " ", |
| 353 | Some("^\\s+$"), |
| 354 | true, |
| 355 | ), |
| 356 | ( |
| 357 | "complex unicode pattern", |
| 358 | "test@example.rs", |
| 359 | Some("^[\\p{L}\\p{N}.@]+$"), |
| 360 | true, |
| 361 | ), |
| 362 | ( |
| 363 | "digit pattern with letters should fail", |
| 364 | "abc123", |
| 365 | Some("^\\d+$"), |
| 366 | false, |
| 367 | ), |
| 368 | ( |
| 369 | "optional pattern with valid input", |
| 370 | "test123", |
| 371 | Some("^[a-z]+\\d*$"), |
| 372 | true, |
| 373 | ), |
| 374 | ]; |
| 375 | |
| 376 | for (description, value, pattern, should_succeed) in edge_cases.iter() { |
| 377 | let pattern_string = pattern.map(|p| p.to_string()); |
| 378 | let result = validate_pattern( |
| 379 | "test_field", |
| 380 | &Value::String(value.to_string()), |
| 381 | pattern_string.as_ref(), |
| 382 | ); |
| 383 | |
| 384 | if *should_succeed { |
| 385 | assert!( |
| 386 | result.is_ok(), |
| 387 | "Test '{}' should succeed but failed: {:?}", |
nothing calls this directly
no test coverage detected