use sre_engine::constants::SreFlag;
use sre_engine::engine;

struct Pattern {
    code: &'static [u32],
    flags: SreFlag,
}

impl Pattern {
    fn state<'a>(
        &self,
        string: impl Into<engine::StrDrive<'a>>,
        range: std::ops::Range<usize>,
    ) -> engine::State<'a> {
        engine::State::new(string.into(), range.start, range.end, self.flags, self.code)
    }
}

#[test]
fn test_2427() {
    // pattern lookbehind = re.compile(r'(?<!\.)x\b')
    // START GENERATED by generate_tests.py
    #[rustfmt::skip] let lookbehind = Pattern { code: &[15, 4, 0, 1, 1, 5, 5, 1, 17, 46, 1, 17, 120, 6, 10, 1], flags: SreFlag::from_bits_truncate(32) };
    // END GENERATED
    let mut state = lookbehind.state("x", 0..usize::MAX);
    state = state.pymatch();
    assert!(state.has_matched == Some(true));
}

#[test]
fn test_assert() {
    // pattern positive_lookbehind = re.compile(r'(?<=abc)def')
    // START GENERATED by generate_tests.py
    #[rustfmt::skip] let positive_lookbehind = Pattern { code: &[15, 4, 0, 3, 3, 4, 9, 3, 17, 97, 17, 98, 17, 99, 1, 17, 100, 17, 101, 17, 102, 1], flags: SreFlag::from_bits_truncate(32) };
    // END GENERATED
    let mut state = positive_lookbehind.state("abcdef", 0..usize::MAX);
    state = state.search();
    assert!(state.has_matched == Some(true));
}
