You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: test.rs
    path of file: ./repos/pomsky/pomsky-bin/src
    
    the code of the file until where you have to start completion: use pcre2::bytes::Regex;
use pomsky::{
    diagnose::{Diagnostic, DiagnosticCode, Severity},
    features::PomskyFeatures,
    options::{CompileOptions, RegexFlavor},
    test::{CaptureIdent, TestCase, TestCaseMatch, TestCaseMatchAll, TestCaseReject},
    Expr,
};

pub(crate) fn run_tests(
    parsed: Expr<'_>,
    input: &str,
    options: CompileOptions,
    errors: &mut Vec<Diagnostic>,
) {
    let (Some(pcre_pattern), _) = parsed.compile(
        input,
        CompileOptions {
            flavor: RegexFlavor::Pcre,
            allowed_features: PomskyFeatures::default(),
            ..options
        },
    ) else {
        let msg = "Failed to compile the expression in the PCRE flavor for running tests".into();
        errors.push(Diagnostic::ad_hoc(Severity::Error, None, msg, None));
        return;
    };

    let regex = pcre2::bytes::RegexBuilder::new()
        .jit_if_available(true)
        .ucp(true)
        .utf(true)
        .build(&pcre_pattern);

    let regex = match regex {
        Ok(regex) => regex,
        Err(e) => {
            let help = Some(format!("The compiled regex is {pcre_pattern:?}"));
            errors.push(Diagnostic::ad_hoc(Severity::Error, None, e.to_string(), help));
            return;
        }
    };

    let tests = parsed.extract_tests();
    for test in tests {
        for test_case in test.cases {
            match test_case {
                TestCase::Match(m) => check_test_match(&regex, m, errors),
                TestCase::MatchAll(a)
    
fn check_test_match(regex: &Regex, test_case: TestCaseMatch<'_>, errors: &mut Vec<Diagnostic>) {
    let result = regex.captures(test_case.literal.content.as_bytes());
    match result {
        Ok(Some(captures)) => {
            if captures[0].len() != test_case.literal.content.as_bytes().len() {
                errors.push(Diagnostic::test_failure(
                    test_case.literal.span,
                    DiagnosticCode::TestNoExactMatch,
                    None,
                ));
                return;
            }

            for capture in &test_case.captures {
                let Some(got_capture) = (match capture.ident {
                    CaptureIdent::Name(name) => captures.name(name),
                    CaptureIdent::Index(idx) => captures.get(idx as usize),
                }) else {
                    errors.push(Diagnostic::test_failure(
                        capture.ident_span,
                        DiagnosticCode::TestMissingCaptureGroup,
                        None,
                    ));
                    continue;
                };
                if got_capture.as_bytes() != capture.literal.content.as_bytes() {
                    errors.push(Diagnostic::test_failure(
                        capture.literal.span,
                        DiagnosticCode::TestWrongCaptureGroup,
                        Some(&String::from_utf8_lossy(got_capture.as_bytes())),
                    ));
                }
            }
        }
        Ok(None) => {
            errors.push(Diagnostic::test_failure(
                test_case.literal.span,
                DiagnosticCode::TestNoExactMatch,
                None,
            ));
        }
        Err(e) => {
            let help = Some(format!("The compiled regex is {:?}", regex.as_str()));
            errors.push(Diagnostic::ad_hoc(Severity::Error, None, e.to_string(), help));
        }
    }
}