Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions pkgs/id/crates/id-core/src/world_presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,93 @@ mod tests {
assert_eq!(invalid.apply(&previous), None);
}

#[test]
fn patch_refuses_a_control_character_replacement() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prefix the new regression tests with test_

The four newly added tests use patch_refuses_... names without the required test_ prefix. The Naming guideline in pkgs/id/AGENTS.md explicitly requires this prefix for tests; rename all four additions to follow that scoped convention.

AGENTS.md reference: pkgs/id/AGENTS.md:L140-L140

Useful? React with 👍 / 👎.

let previous = grid(2, 1, " ");
let invalid = ScreenPatch {
version: 1,
width: 2,
height: 1,
runs: vec![CellRun {
start: 0,
cells: vec![cell("\x1b")],
}],
};

assert_eq!(invalid.apply(&previous), None);
}

#[test]
fn patch_refuses_a_narrow_replacement_that_leaves_an_orphaned_continuation() {
let previous = ScreenSurface::from_cells(
2,
1,
vec![
ScreenCell {
symbol: "界".to_owned(),
columns: 2,
..cell("界")
},
ScreenCell {
symbol: String::new(),
columns: 0,
..cell("")
},
],
)
.unwrap();
let invalid = ScreenPatch {
version: 1,
width: 2,
height: 1,
runs: vec![CellRun {
start: 0,
cells: vec![cell("x")],
}],
};

assert_eq!(invalid.apply(&previous), None);
}

#[test]
fn patch_refuses_a_cell_with_an_invalid_column_count() {
let previous = grid(2, 1, " ");
let invalid = ScreenPatch {
version: 1,
width: 2,
height: 1,
runs: vec![CellRun {
start: 0,
cells: vec![ScreenCell {
columns: 3,
..cell("x")
}],
}],
};

assert_eq!(invalid.apply(&previous), None);
}

#[test]
fn patch_refuses_a_wide_glyph_in_the_last_column_of_a_row() {
let previous = grid(2, 1, " ");
let invalid = ScreenPatch {
version: 1,
width: 2,
height: 1,
runs: vec![CellRun {
start: 1,
cells: vec![ScreenCell {
symbol: "界".to_owned(),
columns: 2,
..cell("界")
}],
}],
};

assert_eq!(invalid.apply(&previous), None);
}

#[test]
fn ansi_diff_repaints_changed_rows_with_terminal_parity_and_byte_savings() {
let previous = grid(80, 24, " ");
Expand Down
Loading