//! The RE2 pattern is the Rust-usable variant: it compiles in the `regex` crate
//! and matches full emoji sequences. The README steers Rust callers to it, so
//! pin that claim with a test.

mod common;

use common::{default_sorted_sequences, golden, VERSIONS};
use emoji_test_regex_pattern::OutputKind;
use regex::Regex;

#[test]
fn re2_is_rust_usable_and_matches_every_sequence() {
    for &dir in VERSIONS {
        let pattern = golden(dir, OutputKind::CppRe2);
        let re = Regex::new(&format!("^(?:{})", pattern.trim()))
            .unwrap_or_else(|e| panic!("{dir}: cpp-re2 did not compile in regex: {e}"));
        for s in default_sorted_sequences(dir) {
            let m = re
                .find(&s)
                .unwrap_or_else(|| panic!("{dir}: no match for {s:?}"));
            assert_eq!(m.start(), 0, "{dir}: match not at start for {s:?}");
            assert_eq!(m.as_str(), s, "{dir}: partial match for {s:?}");
        }
    }
}
