vampirc / vampirc-uci

A Universal Chess Interface (UCI) protocol parser and message generator.
https://vampirc.kejzar.si
Apache License 2.0
19 stars 7 forks source link

Make parse_with_unknown(...) more robust #22

Closed MadMatt04 closed 2 years ago

MadMatt04 commented 3 years ago

Currently parse_with_unknown mostly just gives up on any unrecognized input, wrapping it in a UciMessage::Unknown. It should make a better effort trying to parse what it can and only wrap the unknown part when it encounters it.

See this partially commented out test that should pass when uncommented to get the functionality we want:

#[test]
    fn test_no_line_at_end_parse_with_unknown_with_unknown() {
        let msgs = parse_with_unknown("uci\ndebug on\nucinewgame\nabc\nstop\nquit");
        assert_eq!(msgs.len(), 1);
        // assert_eq!(msgs[0], UciMessage::Uci);
        // assert_eq!(msgs[1], UciMessage::Debug(true));
        // assert_eq!(msgs[2], UciMessage::UciNewGame);
        // assert_eq!(msgs[4], UciMessage::Stop);
        // assert_eq!(msgs[5], UciMessage::Quit);
    }