sashite-feen 0.1.0

Field Expression Encoding Notation (FEEN): a compact, ASCII-only, no_std, zero-allocation validator and encoder for board-game positions in abstract strategy games, built on EPIN and SIN.
Documentation
//! Integration tests for the zero-allocation [`Display`](core::fmt::Display)
//! encoder on the borrowing view. `to_string` and writing into a `String` are
//! provided by the test binary's `std`, so these need no crate feature: the
//! `Display` impl itself never allocates.

use sashite_feen::Feen;

fn round_trip(s: &str) {
    let feen = Feen::parse(s).expect("valid");
    assert_eq!(feen.to_string(), s, "round-trip mismatch");
}

#[test]
fn round_trips() {
    round_trip("8/8/8/8/8/8/8/8 / W/w");
    round_trip("-rnbqk^bn-r/+p+p+p+p+p+p+p+p/8/8/8/8/+P+P+P+P+P+P+P+P/-RNBQK^BN-R / W/w");
    round_trip("lnsgk^gsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGK^GSNL / J/j");
    round_trip("rheag^aehr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RHEAG^AEHR / C/c");
    round_trip("k^+p4+PK^ / C/c");
    round_trip("ab/cd//AB/CD / G/g");
    round_trip("8/8/8/8/8/8/8/8 3P2B/3p2b W/w");
    round_trip("8/8/8/8/8/8/8/8 / c/C"); // second to move
    round_trip("k^ / J/j");
}

#[test]
fn write_into_sink() {
    use core::fmt::Write;
    let feen = Feen::parse("k^+p4+PK^ / C/c").unwrap();
    let mut buf = String::new();
    write!(buf, "{feen}").unwrap();
    assert_eq!(buf, "k^+p4+PK^ / C/c");
}