use justerm_core::Engine;
#[test]
fn insert_mode_shifts_the_tail_right() {
let mut t = Engine::new(5, 1);
t.feed(b"abc"); t.feed(b"\x1b[1;1H"); t.feed(b"\x1b[4h"); t.feed(b"X"); assert_eq!(t.grid().cell(0, 0).c(), 'X');
assert_eq!(t.grid().cell(0, 1).c(), 'a');
assert_eq!(t.grid().cell(0, 2).c(), 'b');
assert_eq!(t.grid().cell(0, 3).c(), 'c');
}
#[test]
fn replace_is_the_default() {
let mut t = Engine::new(5, 1);
t.feed(b"abc\x1b[1;1HX"); assert_eq!(t.grid().cell(0, 0).c(), 'X');
assert_eq!(t.grid().cell(0, 1).c(), 'b'); }
#[test]
fn reset_mode_returns_to_replace() {
let mut t = Engine::new(5, 1);
t.feed(b"abc\x1b[1;1H");
t.feed(b"\x1b[4h"); t.feed(b"\x1b[4l"); t.feed(b"X");
assert_eq!(t.grid().cell(0, 0).c(), 'X');
assert_eq!(t.grid().cell(0, 1).c(), 'b'); }
#[test]
fn insert_discards_cells_past_the_right_margin() {
let mut t = Engine::new(3, 1);
t.feed(b"abc"); t.feed(b"\x1b[1;1H\x1b[4h");
t.feed(b"X"); assert_eq!(t.grid().cell(0, 0).c(), 'X');
assert_eq!(t.grid().cell(0, 1).c(), 'a');
assert_eq!(t.grid().cell(0, 2).c(), 'b');
}
#[test]
fn insert_mode_shifts_a_wide_glyph_coherently() {
let mut t = Engine::new(6, 1);
t.feed(b"abcd"); t.feed(b"\x1b[1;1H\x1b[4h");
t.feed("世".as_bytes()); assert_eq!(t.grid().cell(0, 0).c(), '世');
assert_eq!(t.grid().cell(0, 2).c(), 'a'); assert_eq!(t.grid().cell(0, 3).c(), 'b');
assert_eq!(t.grid().cell(0, 4).c(), 'c');
assert_eq!(t.grid().cell(0, 5).c(), 'd');
}