futtl 0.2.1

Rust bindings for the FUTTL terminal UI library
use crate::Attr;
use crate::Futtl;
use crate::FuttlWin;
use crate::FuttlReturnType;
use crate::FuttlBox;

#[test]
fn test_init() {
    let mut ctx: FuttlWin = FuttlWin::new(1, Attr::NONE);

    assert_eq!(ctx.get_ctx().has_init, 1);
}

#[test]
fn test_box_init() {
    let mut ctx: FuttlWin = FuttlWin::new(1, Attr::NONE);

    let _child: usize = ctx.create_box(10, 5);

    assert_eq!(ctx.get_ctx().child_count, 1);
}

#[test]
fn test_drawing() {
    let mut ctx: FuttlWin = FuttlWin::new(1, Attr::NONE);

    ctx.set_curs(0, 0);

    ctx.write_str("Hello");

    ctx.show();
}


fn test_mainloop_loop(ctx: &mut FuttlWin) -> FuttlReturnType {
    ctx.set_curs(0, 0);
    ctx.write_char('a');
    
    FuttlReturnType {
        is_exit: true,
        status: 0
    }
}

#[test]
fn test_mainloop() {
    let mut ctx: FuttlWin = FuttlWin::new(1, Attr::NONE);

    assert_eq!(ctx.mainloop(test_mainloop_loop), 0);
}