Skip to main content

ironwork_exec/
terminal.rs

1//! rt's 3270 terminal, with its AID bytes checked against the DFHAID copybook `syntax` serves.
2
3pub use rt::terminal::*;
4
5#[cfg(test)]
6mod tests {
7    use super::*;
8
9    #[test]
10    fn aid_bytes_match_the_dfhaid_copybook() {
11        let copybook = syntax::system::member("DFHAID").unwrap();
12        let dfh = |name: &str| -> u8 {
13            let line = copybook.lines().find(|l| l.split_whitespace().nth(1) == Some(name)).unwrap();
14            let hex = line.split("X'").nth(1).unwrap().split('\'').next().unwrap();
15            u8::from_str_radix(hex, 16).unwrap()
16        };
17        for (name, aid) in [("DFHENTER", AID_ENTER), ("DFHCLEAR", AID_CLEAR), ("DFHPA1", AID_PA1), ("DFHPA2", AID_PA2), ("DFHPA3", AID_PA3)] {
18            assert_eq!(dfh(name), aid, "{name}");
19        }
20        for n in 1..=24 {
21            assert_eq!(aid_of(&format!("PF{n}")), Some(dfh(&format!("DFHPF{n}"))), "PF{n}");
22        }
23    }
24}