/*
 * The simplest example
 */

extern crate macrohelper;
use macrohelper::{MacroInput,FromLiteral};


fn main() {

    //the example string
    let dut = r#"

        #[DoTheThing = 15 ]
        pub enum ValEnum {
            Foo,
            Bar
        }
    "#;

    //attempt to parse
    let help = MacroInput::from_str(dut).expect("simple_enum.rs failed to parse");

    //check the attr
    assert!( help.attr.len() == 1);
    assert_eq!( help.attr[0].get_name().unwrap(), "DoTheThing");
    assert_eq!( help.attr[0].from_literal().unwrap(), FromLiteral::Int(15));

    //check the id
    assert_eq!( &help.id, "ValEnum");

    //check the body
    assert!( help.body.is_enum() );
    let body = help.body.get_enum().unwrap();
    assert_eq!(body.len(), 2);
    assert!( body[0].data.is_unit());
    assert_eq!( body[0].get_name(), "Foo");
    assert!( body[1].data.is_unit());
    assert_eq!( body[1].get_name(), "Bar");
    assert!(body.is_unit());
}