#![cfg(feature = "serde")]

use serde::{Deserialize, Serialize};

use kcan::{
    ActuatorConfig, ActuatorFeedback, ActuatorHealth, ActuatorMetric, ActuatorProtocol,
    ActuatorSnapshot, CanId, ControlMode, DirectCommand, FaultCode, HelperPolicy, MitCommand,
    MitHelperCommand, MotorConfig, MotorFeedback, MotorModel, OriginMode, RobStrideCommand,
    RobStrideFeedback, RobStrideFrameKind, RobStrideMitCommand, RobStrideModel,
    RobStridePositionCommand, RobStrideRawCommand, RobStrideSpeedCommand,
};

#[cfg(feature = "tui")]
use kcan::{CanMonitorCommand, TuiCommand, TuiControlIntent, TuiMode, TuiTarget};

#[test]
fn actuator_and_config_types_implement_serde() {
    assert_serde::<CanId>();
    assert_serde::<MotorConfig>();
    assert_serde::<HelperPolicy>();
    assert_serde::<ActuatorProtocol>();
    assert_serde::<ActuatorConfig>();
    assert_serde::<ActuatorFeedback>();
    assert_serde::<ActuatorHealth>();
    assert_serde::<ActuatorMetric>();
    assert_serde::<ActuatorSnapshot>();
}

#[test]
fn cubemars_protocol_types_implement_serde() {
    assert_serde::<MotorModel>();
    assert_serde::<ControlMode>();
    assert_serde::<DirectCommand>();
    assert_serde::<OriginMode>();
    assert_serde::<MitCommand>();
    assert_serde::<MitHelperCommand>();
    assert_serde::<MotorFeedback>();
    assert_serde::<FaultCode>();
}

#[test]
fn robstride_protocol_types_implement_serde() {
    assert_serde::<RobStrideModel>();
    assert_serde::<RobStrideFrameKind>();
    assert_serde::<RobStrideMitCommand>();
    assert_serde::<RobStridePositionCommand>();
    assert_serde::<RobStrideSpeedCommand>();
    assert_serde::<RobStrideRawCommand>();
    assert_serde::<RobStrideCommand>();
    assert_serde::<RobStrideFeedback>();
}

#[cfg(feature = "tui")]
#[test]
fn tui_intent_types_implement_serde() {
    assert_serde::<TuiMode>();
    assert_serde::<TuiTarget>();
    assert_serde::<TuiCommand>();
    assert_serde::<TuiControlIntent>();
    assert_serde::<CanMonitorCommand>();
}

fn assert_serde<T>()
where
    T: Serialize + for<'de> Deserialize<'de>,
{
}
