use super::*;
use dtee::Controller;
#[test]
fn larger_view() {
let expected = r#"
┌───────┐
│ SLA │
├───┬───┴─────────────┬───────────────╥─────┐
│ U │ YearsAsCustomer │ NumberOfUnits ║ SLA │
│ ├─────────────────┼───────────────╫─────┤
│ │ [0..100] │ [0..1000000] ║ 1,2 │
╞═══╪═════════════════╪═══════════════╬═════╡
│ 1 │ <2 │ <1000 ║ 1 │
├───┼─────────────────┼───────────────╫─────┤
│ 2 │ <2 │ >=1000 ║ 2 │
├───┼─────────────────┼───────────────╫─────┤
│ 3 │ >=2 │ <500 ║ 1 │
├───┼─────────────────┼───────────────╫─────┤
│ 4 │ >=2 │ >=500 ║ 2 │
└───┴─────────────────┴───────────────╨─────┘
"#;
const WIDTH: usize = 300; const HEIGHT: usize = 200;
let mut controller = Controller::new(INPUT_0001).with_viewport(WIDTH, HEIGHT);
assert_eq!(expected, text(&controller));
assert_eq!(format!("(0, 0, {WIDTH}, {HEIGHT})"), controller.viewport().to_string());
assert_eq!((1, 1), controller.cursor().pos());
assert_eq!("(0, 0, 45, 15)", controller.content_region().to_string());
}
#[test]
fn smaller_view() {
let expected = r#"
┌───────┐
│ SLA │
├───┬───┴─────────────┬───────────────╥─────┐
│ U │ YearsAsCustomer │ NumberOfUnits ║ SLA │
│ ├─────────────────┼───────────────╫─────┤
│ │ [0..100] │ [0..1000000] ║ 1,2 │
╞═══╪═════════════════╪═══════════════╬═════╡
│ 1 │ <2 │ <1000 ║ 1 │
├───┼─────────────────┼───────────────╫─────┤
│ 2 │ <2 │ >=1000 ║ 2 │
├───┼─────────────────┼───────────────╫─────┤
│ 3 │ >=2 │ <500 ║ 1 │
├───┼─────────────────┼───────────────╫─────┤
│ 4 │ >=2 │ >=500 ║ 2 │
└───┴─────────────────┴───────────────╨─────┘
"#;
const WIDTH: usize = 10; const HEIGHT: usize = 6;
let mut controller = Controller::new(INPUT_0001).with_viewport(10, 6);
assert_eq!(expected, text(&controller));
assert_eq!(format!("(0, 0, {WIDTH}, {HEIGHT})"), controller.viewport().to_string());
assert_eq!((1, 1), controller.cursor().pos());
assert_eq!("(0, 0, 45, 15)", controller.content_region().to_string());
}
#[test]
fn empty_lines_are_skipped() {
let mut controller1 = Controller::new(INPUT_0001).with_viewport(600, 600);
let mut controller2 = Controller::new(INPUT_0003).with_viewport(600, 600);
assert_eq!(controller1.content(), controller2.content());
assert_eq!(controller1.content_region(), controller2.content_region());
assert_eq!(text(&controller1), text(&controller2));
}