use super::*;
#[test]
fn test_truncate_fits_entirely() {
assert_eq!(truncate_to_width("hi", 10), "hi");
}
#[test]
fn test_truncate_exact_fit() {
assert_eq!(truncate_to_width("hello", 5), "hello");
}
#[test]
fn test_truncate_longer_than_max() {
assert_eq!(truncate_to_width("hello world", 5), "hello");
}
#[test]
fn test_truncate_empty_string() {
assert_eq!(truncate_to_width("", 5), "");
}
#[test]
fn test_truncate_zero_width() {
assert_eq!(truncate_to_width("hello", 0), "");
}
#[test]
fn test_truncate_cjk_full_fit() {
assert_eq!(truncate_to_width("世界", 4), "世界");
}
#[test]
fn test_truncate_cjk_partial() {
assert_eq!(truncate_to_width("世界", 3), "世");
}
#[test]
fn test_truncate_cjk_too_narrow() {
assert_eq!(truncate_to_width("世界", 1), "");
}
#[test]
fn test_truncate_mixed_ascii_cjk() {
assert_eq!(truncate_to_width("a世b", 4), "a世b");
assert_eq!(truncate_to_width("a世b", 3), "a世");
assert_eq!(truncate_to_width("a世b", 2), "a");
}
#[test]
fn test_truncate_boundary_cjk() {
assert_eq!(truncate_to_width("世", 2), "世");
assert_eq!(truncate_to_width("世", 1), "");
}
#[test]
fn test_truncate_emoji() {
let result = truncate_to_width("😀hello", 3);
assert_eq!(result, "😀h");
}
#[test]
fn test_wrapped_single_line_fits() {
assert_eq!(wrapped_line_count("hello", 10), 1);
}
#[test]
fn test_wrapped_empty_string() {
assert_eq!(wrapped_line_count("", 10), 1);
}
#[test]
fn test_wrapped_explicit_newlines() {
assert_eq!(wrapped_line_count("a\nb\nc", 10), 3);
}
#[test]
fn test_wrapped_trailing_newline() {
assert_eq!(wrapped_line_count("a\n", 10), 2);
}
#[test]
fn test_wrapped_character_wrapping() {
assert_eq!(wrapped_line_count("hello world", 5), 3);
}
#[test]
fn test_wrapped_exact_width() {
assert_eq!(wrapped_line_count("hello", 5), 1);
}
#[test]
fn test_wrapped_zero_width() {
assert_eq!(wrapped_line_count("hello", 0), 0);
}
#[test]
fn test_wrapped_zero_width_empty() {
assert_eq!(wrapped_line_count("", 0), 0);
}
#[test]
fn test_wrapped_cjk_wrapping() {
assert_eq!(wrapped_line_count("世界你好", 5), 2);
}
#[test]
fn test_wrapped_cjk_bump_to_next_line() {
assert_eq!(wrapped_line_count("ab世", 3), 2);
}
#[test]
fn test_wrapped_multiple_wraps() {
assert_eq!(wrapped_line_count("abcdefghij", 3), 4);
}
#[test]
fn test_wrapped_mixed_newlines_and_wrapping() {
assert_eq!(wrapped_line_count("abcdef\nghij", 4), 3);
}
#[test]
fn test_wrapped_width_one() {
assert_eq!(wrapped_line_count("abc", 1), 3);
}
#[test]
fn test_wrapped_only_newlines() {
assert_eq!(wrapped_line_count("\n\n", 10), 3);
}
#[test]
fn test_wrapped_single_char() {
assert_eq!(wrapped_line_count("a", 1), 1);
assert_eq!(wrapped_line_count("a", 10), 1);
}
#[test]
fn test_wrapped_long_cjk_line() {
assert_eq!(wrapped_line_count("世界世界世界", 4), 3);
}
#[test]
fn test_wrapped_cjk_odd_width() {
assert_eq!(wrapped_line_count("世界", 3), 2);
}