use noyalib::{from_str, Value};
#[test]
fn null_tilde() {
let v: Value = from_str("~").unwrap();
assert!(v.is_null());
}
#[test]
fn null_word() {
let v: Value = from_str("null").unwrap();
assert!(v.is_null());
}
#[test]
fn null_uppercase_is_string() {
let v: Value = from_str("Null").unwrap();
assert!(v.is_string() || v.is_null());
}
#[test]
fn null_all_caps_is_string() {
let v: Value = from_str("NULL").unwrap();
assert!(v.is_string() || v.is_null());
}
#[test]
fn null_empty_value() {
let v: Value = from_str("---\n").unwrap();
assert!(v.is_null());
}
#[test]
fn null_in_mapping() {
let v: Value = from_str("key:\n").unwrap();
assert!(v.get("key").unwrap().is_null());
}
#[test]
fn null_option() {
let v: Option<i64> = from_str("~").unwrap();
assert!(v.is_none());
}
#[test]
fn bool_true() {
let v: bool = from_str("true").unwrap();
assert!(v);
}
#[test]
fn bool_false() {
let v: bool = from_str("false").unwrap();
assert!(!v);
}
#[test]
fn bool_True_is_string() {
let v: Value = from_str("True").unwrap();
assert!(v.is_string() || v.is_bool());
}
#[test]
fn bool_FALSE_is_string() {
let v: Value = from_str("FALSE").unwrap();
assert!(v.is_string() || v.is_bool());
}
#[test]
fn bool_in_mapping() {
let v: Value = from_str("flag: true\nother: false\n").unwrap();
assert_eq!(v.get("flag").unwrap().as_bool(), Some(true));
assert_eq!(v.get("other").unwrap().as_bool(), Some(false));
}
#[test]
fn bool_in_sequence() {
let v: Vec<bool> = from_str("- true\n- false\n- true\n").unwrap();
assert_eq!(v, vec![true, false, true]);
}