use crate::value::Value;

#[test]
fn test_value_display() {
    assert_eq!(Value::Int(42).to_string(), "42");
    assert_eq!(Value::Double(3.14).to_string(), "3.14");
    assert_eq!(Value::String("hello".to_string()).to_string(), "'hello'");
    assert_eq!(Value::Boolean(true).to_string(), "true");
    assert_eq!(Value::Null.to_string(), "NULL");
    assert_eq!(Value::Unknown.to_string(), "UNKNOWN");
}

#[test]
fn test_binary_value_display() {
    let binary = Value::Binary(vec![0xDE, 0xAD, 0xBE, 0xEF]);
    assert_eq!(binary.to_string(), "0xdeadbeef");
}

#[test]
fn test_array_display() {
    let array = Value::Array(vec![Value::Int(1), Value::Int(2), Value::Int(3)]);
    assert_eq!(array.to_string(), "[1, 2, 3]");
}

#[test]
fn test_tuple_display() {
    let tuple = Value::Tuple(vec![
        Value::Int(1),
        Value::String("hello".to_string()),
        Value::Boolean(true),
    ]);
    assert_eq!(tuple.to_string(), "(1, 'hello', true)");
}

#[test]
fn test_value_equality() {
    assert_eq!(Value::Int(42), Value::Int(42));
    assert_ne!(Value::Int(42), Value::Int(43));

    assert_eq!(
        Value::String("hello".to_string()),
        Value::String("hello".to_string())
    );
    assert_ne!(
        Value::String("hello".to_string()),
        Value::String("world".to_string())
    );

    assert_eq!(Value::Null, Value::Null);
    assert_ne!(Value::Null, Value::Int(0));
}

#[test]
fn test_range_display() {
    use crate::value::RangeValue;

    // Range with both bounds
    let range = Value::Range(Box::new(RangeValue {
        lower: Some(Value::Int(3)),
        upper: Some(Value::Int(7)),
    }));
    assert_eq!(range.to_string(), "3..7");

    // Range with only lower bound
    let range = Value::Range(Box::new(RangeValue {
        lower: Some(Value::Int(5)),
        upper: None,
    }));
    assert_eq!(range.to_string(), "5..");

    // Range with only upper bound
    let range = Value::Range(Box::new(RangeValue {
        lower: None,
        upper: Some(Value::Int(10)),
    }));
    assert_eq!(range.to_string(), "..10");

    // Empty range
    let range = Value::Range(Box::new(RangeValue {
        lower: None,
        upper: None,
    }));
    assert_eq!(range.to_string(), "..");
}

#[test]
fn test_is_null() {
    assert!(Value::Null.is_null());
    assert!(!Value::Int(0).is_null());
    assert!(!Value::String("".to_string()).is_null());
    assert!(!Value::Boolean(false).is_null());
    assert!(!Value::Unknown.is_null());
    assert!(!Value::Array(vec![]).is_null());
    assert!(!Value::Array(vec![Value::Null]).is_null());
}
