use std::error::Error;

use crate::{Datum, Expr};

#[test]
fn text_parses() -> Result<(), Box<dyn Error>> {
    assert_eq!(
        Expr::try_from("'Hello, World!'")?,
        Expr::Literal(Datum::Text(Some("Hello, World!".to_owned())))
    );
    Ok(())
}

#[test]
fn escaped_quotes_parse() -> Result<(), Box<dyn Error>> {
    assert_eq!(
        Expr::try_from("'''Hello, World!'''")?,
        Expr::Literal(Datum::Text(Some("'Hello, World!'".to_owned())))
    );
    Ok(())
}

#[test]
fn numeric_parses() -> Result<(), Box<dyn Error>> {
    assert_eq!(
        Expr::try_from("1234.56")?,
        Expr::Literal(Datum::Numeric(Some("1234.56".parse()?)))
    );
    Ok(())
}
