in uniffi_udl/src/literal.rs [111:152]
fn test_default_value_conversion() -> Result<()> {
assert!(matches!(
parse_and_convert("0", Type::UInt8)?,
Literal::UInt(0, Radix::Decimal, Type::UInt8)
));
assert!(matches!(
parse_and_convert("-12", Type::Int32)?,
Literal::Int(-12, Radix::Decimal, Type::Int32)
));
assert!(
matches!(parse_and_convert("3.14", Type::Float32)?, Literal::Float(v, Type::Float32) if v == "3.14")
);
assert!(matches!(
parse_and_convert("false", Type::Boolean)?,
Literal::Boolean(false)
));
assert!(
matches!(parse_and_convert("\"TEST\"", Type::String)?, Literal::String(v) if v == "TEST")
);
assert!(
matches!(parse_and_convert("\"one\"", Type::Enum { name: "E".into(), module_path: "".into() })?, Literal::Enum(v, Type::Enum { name, .. }) if v == "one" && name == "E")
);
assert!(matches!(
parse_and_convert(
"[]",
Type::Sequence {
inner_type: Box::new(Type::String)
}
)?,
Literal::EmptySequence
));
assert!(matches!(
parse_and_convert(
"null",
Type::Optional {
inner_type: Box::new(Type::String)
}
)?,
Literal::None
));
Ok(())
}