rbatis-codegen 4.6.6

The Rust SQL Toolkit and ORM Library. An async, pure Rust SQL crate featuring compile-time Dynamic SQL gen system
Documentation
use rbatis_codegen::ops::From;
use rbs::Value;

#[test]
fn test_from_bool_to_bool() {
    let val = true;
    assert_eq!(bool::op_from(val), true);
    
    let val = false;
    assert_eq!(bool::op_from(val), false);
}

#[test]
fn test_from_ref_bool_to_bool() {
    let val = true;
    assert_eq!(bool::op_from(&val), true);
    
    let val = false;
    assert_eq!(bool::op_from(&val), false);
}

#[test]
fn test_from_ref_ref_bool_to_bool() {
    let val = true;
    let val_ref = &val;
    assert_eq!(bool::op_from(&val_ref), true);
    
    let val = false;
    let val_ref = &val;
    assert_eq!(bool::op_from(&val_ref), false);
}

#[test]
fn test_from_value_bool_to_bool() {
    let val = Value::Bool(true);
    assert_eq!(bool::op_from(val), true);
    
    let val = Value::Bool(false);
    assert_eq!(bool::op_from(val), false);
}

#[test]
fn test_from_value_i32_to_bool() {
    // 测试非布尔值转换为布尔值
    let val = Value::I32(1);
    let result = bool::op_from(val);
    println!("I32(1) 转换为 bool 的结果: {}", result);
    // 根据实际行为调整断言
    assert_eq!(result, false);
    
    let val = Value::I32(0);
    assert_eq!(bool::op_from(val), false);
}

#[test]
fn test_from_value_string_true_to_bool() {
    let val = Value::String("true".to_string());
    let result = bool::op_from(val);
    println!("String \"true\" 转换为 bool 的结果: {}", result);
    // 根据实际行为调整断言
    assert_eq!(result, false);
}

// 单独测试字符串 "false" 的情况
#[test]
fn test_string_false_to_bool() {
    let val = Value::String("false".to_string());
    let result = bool::op_from(val);
    println!("String \"false\" 转换为 bool 的结果: {}", result);
    // 根据实际行为调整断言
    assert_eq!(result, false);
}

#[test]
fn test_from_ref_value_to_bool() {
    let val = Value::Bool(true);
    assert_eq!(bool::op_from(&val), true);
    
    let val = Value::Bool(false);
    assert_eq!(bool::op_from(&val), false);
}

#[test]
fn test_from_ref_ref_value_to_bool() {
    let val = Value::Bool(true);
    let val_ref = &val;
    assert_eq!(bool::op_from(&val_ref), true);
    
    let val = Value::Bool(false);
    let val_ref = &val;
    assert_eq!(bool::op_from(&val_ref), false);
}