use rbatis_codegen::ops::From;
use rbs::Value;
#[test]
fn test_from_bool_to_bool() {
let val = true;
assert!(bool::op_from(val));
let val = false;
assert!(!bool::op_from(val));
}
#[test]
fn test_from_ref_bool_to_bool() {
let val = true;
assert!(bool::op_from(&val));
let val = false;
assert!(!bool::op_from(&val));
}
#[test]
fn test_from_ref_ref_bool_to_bool() {
let val = true;
let val_ref = &val;
assert!(bool::op_from(&val_ref));
let val = false;
let val_ref = &val;
assert!(!bool::op_from(&val_ref));
}
#[test]
fn test_from_value_bool_to_bool() {
let val = Value::Bool(true);
assert!(bool::op_from(val));
let val = Value::Bool(false);
assert!(!bool::op_from(val));
}
#[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!(!result);
let val = Value::I32(0);
assert!(!bool::op_from(val));
}
#[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!(!result);
}
#[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!(!result);
}
#[test]
fn test_from_ref_value_to_bool() {
let val = Value::Bool(true);
assert!(bool::op_from(&val));
let val = Value::Bool(false);
assert!(!bool::op_from(&val));
}
#[test]
fn test_from_ref_ref_value_to_bool() {
let val = Value::Bool(true);
let val_ref = &val;
assert!(bool::op_from(&val_ref));
let val = Value::Bool(false);
let val_ref = &val;
assert!(!bool::op_from(&val_ref));
}