]>
Commit | Line | Data |
---|---|---|
1 | use std::fs; | |
2 | use std::io; | |
3 | use term::terminfo::TermInfo; | |
4 | use term::terminfo::TerminfoTerminal; | |
5 | use term::Terminal; | |
6 | ||
7 | #[test] | |
8 | fn test_parse() { | |
9 | for f in fs::read_dir("tests/data/").unwrap() { | |
10 | let _ = TermInfo::from_path(f.unwrap().path()).unwrap(); | |
11 | } | |
12 | } | |
13 | ||
14 | #[test] | |
15 | fn test_supports_color() { | |
16 | fn supports_color(term: &str) -> bool { | |
17 | let terminfo = TermInfo::from_path(format!("tests/data/{}", term)).unwrap(); | |
18 | let term = TerminfoTerminal::new_with_terminfo(io::stdout(), terminfo); | |
19 | term.supports_color() | |
20 | } | |
21 | assert!(supports_color("linux")); | |
22 | assert!(!supports_color("dumb")); | |
23 | } | |
24 | ||
25 | #[test] | |
26 | fn test_fallback() { | |
27 | TermInfo::from_name("ansi-cargo-test").expect("failed to use fallback"); | |
28 | assert!(TermInfo::from_name("really-bad-terminal").is_err()); | |
29 | } |