File size: 1,230 Bytes
854994d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | use super::ScrollableDiff;
use pretty_assertions::assert_eq;
#[test]
fn wraps_halfwidth_sound_marks_using_ratatui_width() {
let mut diff = ScrollableDiff::new();
diff.set_content(vec![
"aガbパc".to_string(),
"a ゙b".to_string(),
"a ゚b".to_string(),
]);
diff.set_width(/*width*/ 2);
insta::assert_snapshot!(
diff.wrapped_lines().join("\n"),
@r"
a
ガ
b
パ
c
a
゙b
a
゚b
"
);
assert_eq!(diff.wrapped_src_indices(), [0, 0, 0, 0, 0, 1, 1, 2, 2]);
}
#[test]
fn does_not_emit_empty_rows_after_full_width_sound_mark_graphemes() {
for grapheme in ["ガ", "パ"] {
let mut diff = ScrollableDiff::new();
diff.set_content(vec![format!("a {grapheme} tail")]);
diff.set_width(/*width*/ 2);
let expected = ["a", grapheme, "ta", "il"];
let actual = diff
.wrapped_lines()
.iter()
.map(String::as_str)
.collect::<Vec<_>>();
assert_eq!(actual, expected);
assert_eq!(diff.wrapped_src_indices(), [0, 0, 0, 0]);
assert_eq!(diff.state.content_h, 4);
}
}
|