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);
}
#[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);
}