// Unit coverage for the shared HID report encoder.
//
// Scope: exercise the smallest pure HID helpers without touching devices.
// Targets: `common/src/hid.rs`.
// Why: paste injection and local key simulation both depend on exact USB HID
// report shapes, so the primitive encoder should fail loudly on drift.

use lesavka_common::hid::{append_char_reports, char_to_usage};

#[test]
fn shifted_printable_character_expands_to_modifier_key_and_release_sequence() {
    let mut reports = Vec::new();

    assert!(append_char_reports(&mut reports, '?'));

    assert_eq!(char_to_usage('?'), Some((0x38, 0x02)));
    assert_eq!(reports.len(), 4);
    assert_eq!(reports[0], [0x02, 0, 0, 0, 0, 0, 0, 0]);
    assert_eq!(reports[1], [0x02, 0, 0x38, 0, 0, 0, 0, 0]);
    assert_eq!(reports[2], [0x02, 0, 0, 0, 0, 0, 0, 0]);
    assert_eq!(reports[3], [0; 8]);
}

#[test]
fn unsupported_unicode_character_does_not_emit_partial_reports() {
    let mut reports = Vec::new();

    assert!(!append_char_reports(&mut reports, '🙂'));

    assert!(reports.is_empty());
}
