use pot_head::{
    Config, ConfigError, HysteresisMode, NoiseFilter, PotHead, ResponseCurve, SnapZone,
};

#[cfg(feature = "grab-mode")]
use pot_head::GrabMode;

static EMPTY_SNAP_ZONES: [SnapZone<f32>; 0] = [];

#[test]
fn test_invalid_input_range() {
    static CONFIG: Config<u16, f32> = Config {
        input_min: 100_u16,
        input_max: 100_u16, // Same as min - invalid
        output_min: 0.0_f32,
        output_max: 1.0_f32,
        hysteresis: HysteresisMode::none(),
        curve: ResponseCurve::Linear,
        filter: NoiseFilter::None,
        snap_zones: &EMPTY_SNAP_ZONES,
        #[cfg(feature = "grab-mode")]
        grab_mode: GrabMode::None,
    };

    let result = PotHead::new(&CONFIG);
    assert!(matches!(result, Err(ConfigError::InvalidInputRange)));
}

#[test]
fn test_inverted_input_range() {
    static CONFIG: Config<u16, f32> = Config {
        input_min: 200_u16,
        input_max: 100_u16, // Less than min - invalid
        output_min: 0.0_f32,
        output_max: 1.0_f32,
        hysteresis: HysteresisMode::none(),
        curve: ResponseCurve::Linear,
        filter: NoiseFilter::None,
        snap_zones: &EMPTY_SNAP_ZONES,
        #[cfg(feature = "grab-mode")]
        grab_mode: GrabMode::None,
    };

    let result = PotHead::new(&CONFIG);
    assert!(matches!(result, Err(ConfigError::InvalidInputRange)));
}

#[test]
fn test_invalid_output_range() {
    static CONFIG: Config<u16, f32> = Config {
        input_min: 0_u16,
        input_max: 100_u16,
        output_min: 1.0_f32,
        output_max: 1.0_f32, // Same as min - invalid
        hysteresis: HysteresisMode::none(),
        curve: ResponseCurve::Linear,
        filter: NoiseFilter::None,
        snap_zones: &EMPTY_SNAP_ZONES,
        #[cfg(feature = "grab-mode")]
        grab_mode: GrabMode::None,
    };

    let result = PotHead::new(&CONFIG);
    assert!(matches!(result, Err(ConfigError::InvalidOutputRange)));
}
