Skip to content

Commit c662e77

Browse files
committed
stty: test parse_saved_state
1 parent 58bccfd commit c662e77

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/uu/stty/src/stty.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,24 @@ mod tests {
14361436
assert_eq!(parse_rows_cols("65537"), Some(1)); // wraps to 1
14371437
}
14381438

1439+
#[test]
1440+
fn test_sane_parse_saved_state() {
1441+
let expected_parts = 4 + nix::libc::NCCS;
1442+
let mut parts: Vec<String> = ["00", "01", "ff", "7f"].map(str::to_string).into();
1443+
parts.resize(expected_parts, "00".to_string());
1444+
let input = parts.join(":");
1445+
assert_eq!(parse_saved_state(&input), None);
1446+
}
1447+
1448+
#[test]
1449+
fn test_parse_saved_state_no_plus() {
1450+
let expected_parts = 4 + nix::libc::NCCS;
1451+
let mut parts: Vec<String> = ["+00", "00", "00", "00"].map(str::to_string).into();
1452+
parts.resize(expected_parts, "00".to_string());
1453+
let input = parts.join(":");
1454+
assert_eq!(parse_saved_state(&input), None);
1455+
}
1456+
14391457
// Sane control character defaults
14401458
#[test]
14411459
fn test_get_sane_control_char_values() {

0 commit comments

Comments
 (0)