use virtual_tty::VirtualTty;
#[test]
fn test_cursor_position_tracking_basic() {
let mut tty = VirtualTty::new(10, 3);
tty.stdout_write("Hello");
let (row, col) = tty.get_cursor_position();
assert_eq!(row, 0);
assert_eq!(col, 5);
}
#[test]
fn test_cursor_position_tracking_comprehensive() {
let mut tty = VirtualTty::new(10, 5);
let (row, col) = tty.get_cursor_position();
assert_eq!((row, col), (0, 0));
tty.stdout_write("Hello");
let (row, col) = tty.get_cursor_position();
assert_eq!((row, col), (0, 5));
tty.stdout_write("\n");
let (row, col) = tty.get_cursor_position();
assert_eq!((row, col), (1, 0));
tty.stdout_write("\x1b[1A"); tty.stdout_write("\x1b[2C"); let (row, col) = tty.get_cursor_position();
assert_eq!((row, col), (0, 2));
}
#[test]
fn test_cursor_tracking_during_scroll() {
let mut tty = VirtualTty::new(10, 2);
tty.stdout_write("Line1\nLine2\nLine3"); let (row, col) = tty.get_cursor_position();
assert_eq!(row, 1); assert_eq!(col, 5); }
#[test]
fn test_relative_movement_after_scroll() {
let mut tty = VirtualTty::new(10, 2);
tty.stdout_write("Line1\nLine2\nLine3"); tty.stdout_write("\x1b[1A"); tty.stdout_write("X");
let snapshot = tty.get_snapshot();
insta::assert_snapshot!(snapshot, @r"
Line2X \n
Line3 \n
");
}
#[test]
fn test_cursor_at_line_boundaries() {
let mut tty = VirtualTty::new(5, 3);
tty.stdout_write("12345678"); let (row, col) = tty.get_cursor_position();
assert_eq!((row, col), (1, 3));
tty.stdout_write("\x1b[1A"); tty.stdout_write("X");
let snapshot = tty.get_snapshot();
insta::assert_snapshot!(snapshot, @r"
123X5\n
678 \n
\n
");
}