use super::*;
#[cfg(not(feature = "std"))]
use alloc::format;
#[test]
fn validate_utf8_valid() {
assert!(validate_utf8_batch(b"Hello, World!").is_ok());
assert!(validate_utf8_batch("Hello, 世界! 🎵".as_bytes()).is_ok());
assert!(validate_utf8_batch("a".repeat(50).as_bytes()).is_ok());
}
#[test]
fn validate_utf8_invalid() {
assert!(validate_utf8_batch(&[0xFF, 0xFE]).is_err());
}
#[test]
fn validate_utf8_empty_input() {
assert!(validate_utf8_batch(&[]).is_ok());
}
#[test]
fn validate_utf8_ascii_only() {
let ascii_text = "Hello, World! 123 @#$%";
assert!(validate_utf8_batch(ascii_text.as_bytes()).is_ok());
}
#[test]
fn validate_utf8_exactly_16_bytes() {
let text = "1234567890123456"; assert!(validate_utf8_batch(text.as_bytes()).is_ok());
}
#[test]
fn validate_utf8_less_than_16_bytes() {
let text = "short"; assert!(validate_utf8_batch(text.as_bytes()).is_ok());
}
#[test]
fn validate_utf8_much_longer() {
let text = "a".repeat(100);
assert!(validate_utf8_batch(text.as_bytes()).is_ok());
}
#[test]
fn validate_utf8_mixed_unicode() {
let text = "ASCII中文🎵عربي";
assert!(validate_utf8_batch(text.as_bytes()).is_ok());
}
#[test]
fn validate_utf8_invalid_sequences() {
assert!(validate_utf8_batch(&[0xC0, 0x80]).is_err()); assert!(validate_utf8_batch(&[0xED, 0xA0, 0x80]).is_err()); assert!(validate_utf8_batch(&[0xF4, 0x90, 0x80, 0x80]).is_err()); }
#[test]
fn validate_utf8_incomplete_sequences() {
assert!(validate_utf8_batch(&[0xC2]).is_err()); assert!(validate_utf8_batch(&[0xE0, 0x80]).is_err()); assert!(validate_utf8_batch(&[0xF0, 0x90, 0x80]).is_err()); }
#[test]
fn validate_utf8_non_ascii_in_chunks() {
let text = format!("{}café", "a".repeat(12)); assert!(validate_utf8_batch(text.as_bytes()).is_ok());
}
#[test]
fn validate_utf8_chunk_remainder_handling() {
let text = format!("{}café", "a".repeat(17)); assert!(validate_utf8_batch(text.as_bytes()).is_ok());
let text2 = format!("{}🎵", "a".repeat(18)); assert!(validate_utf8_batch(text2.as_bytes()).is_ok());
}