roplat 0.2.0

roplat: just a robot operation system
Documentation
// 算术运算节点测试
use roplat::node::*;
use roplat::RoplatError;

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_arithmetic_add() {
        let mut add = arithmetic::OpAdd::<f32>::default();
        let result: f32 = add.process((3.0, 4.0)).await.unwrap();
        assert_eq!(result, 7.0);
    }

    #[tokio::test]
    async fn test_arithmetic_sub() {
        let mut sub = arithmetic::OpSub::<i32>::default();
        let result: i32 = sub.process((10, 3)).await.unwrap();
        assert_eq!(result, 7);
    }

    #[tokio::test]
    async fn test_arithmetic_mul() {
        let mut mul = arithmetic::OpMul::<f64>::default();
        let result: f64 = mul.process((2.5, 4.0)).await.unwrap();
        assert_eq!(result, 10.0);
    }

    #[tokio::test]
    async fn test_arithmetic_div() {
        let mut div = arithmetic::OpDiv::<i32>::default();
        let result: i32 = div.process((10, 2)).await.unwrap();
        assert_eq!(result, 5);
    }

    #[tokio::test]
    async fn test_arithmetic_div_by_zero() {
        let mut div = arithmetic::OpDiv::<i32>::default();
        let result = div.process((10, 0)).await;
        assert!(result.is_err());
        match result {
            Err(RoplatError::Arithmetic(msg)) => {
                assert!(msg.contains("除零"));
            }
            _ => panic!("期望算术错误"),
        }
    }

    #[tokio::test]
    async fn test_arithmetic_rem() {
        let mut rem = arithmetic::OpRem::<i32>::default();
        let result: i32 = rem.process((10, 3)).await.unwrap();
        assert_eq!(result, 1);
    }

    #[tokio::test]
    async fn test_arithmetic_abs() {
        let mut abs = arithmetic::OpAbs::<f32>::default();
        let result: f32 = abs.process(-5.0).await.unwrap();
        assert_eq!(result, 5.0);
    }

    #[tokio::test]
    async fn test_arithmetic_min_max() {
        let mut max = arithmetic::OpMax::<i32>::default();
        let result: i32 = max.process((5, 10)).await.unwrap();
        assert_eq!(result, 10);

        let mut min = arithmetic::OpMin::<i32>::default();
        let result: i32 = min.process((5, 10)).await.unwrap();
        assert_eq!(result, 5);
    }

    #[tokio::test]
    async fn test_arithmetic_chain() {
        // 测试算术运算链:(5 + 3) * 2 = 16
        let mut add = arithmetic::OpAdd::<i32>::default();
        let mut mul = arithmetic::OpMul::<i32>::default();

        let sum: i32 = add.process((5, 3)).await.unwrap();
        let product: i32 = mul.process((sum, 2)).await.unwrap();

        assert_eq!(product, 16);
    }
}