use core::periph::kim1_keypad::Kim1Keypad;

#[test]
fn keys_are_pressed() {
    let mut kb = Kim1Keypad::new();

    for index in 0..23 {
        assert!(!kb.is_pressed(index));
        kb.press_key(index);
        assert!(kb.is_pressed(index));

        kb.release_key(index);
        assert!(!kb.is_pressed(index));
    }
}

#[test]
fn stepping_changes() {
    let mut kb = Kim1Keypad::new();

    kb.set_stepping(false);

    assert!(!kb.stepping);

    kb.toggle_stepping();

    assert!(kb.stepping);

    kb.toggle_stepping();
    kb.toggle_stepping();
    kb.toggle_stepping();
    kb.toggle_stepping();
    kb.toggle_stepping();

    assert!(!kb.stepping);
}

#[test]
fn out_of_range() {
    let mut kb = Kim1Keypad::new();

    kb.press_key(24);
    assert!(kb.is_pressed(1));
}