File: settings.rs

package info (click to toggle)
rust-ptyprocess 0.4.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 260 kB
  • sloc: makefile: 4
file content (38 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (2)
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
use ptyprocess::PtyProcess;
use std::{process::Command, time::Duration};

#[test]
fn default_win_size() {
    let proc = PtyProcess::spawn(Command::new("cat")).unwrap();

    assert_eq!(proc.get_window_size().unwrap(), (80, 24));
}

#[test]
fn set_win_size() {
    let mut proc = PtyProcess::spawn(Command::new("cat")).unwrap();

    proc.set_window_size(100, 200).unwrap();

    assert_eq!(proc.get_window_size().unwrap(), (100, 200));
}

#[test]
fn default_echo() {
    let proc = PtyProcess::spawn(Command::new("cat")).unwrap();
    assert!(!proc.get_echo().unwrap());
}

#[test]
fn set_echo() {
    let mut proc = PtyProcess::spawn(Command::new("cat")).unwrap();

    assert!(proc.isatty().unwrap());

    let is_set = proc
        .set_echo(true, Some(Duration::from_millis(500)))
        .unwrap();

    assert!(is_set);
    assert!(proc.get_echo().unwrap());
}