From fc17126cbf164beb8fd3a7f367ac23809ef0da96 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Wed, 19 Aug 2026 11:13:24 +0200 Subject: [PATCH] Split REGEXP_EXTRACT group tests --- jitexpr/src/functions/regexp_extract.rs | 31 +++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/jitexpr/src/functions/regexp_extract.rs b/jitexpr/src/functions/regexp_extract.rs index 17a884c9d..12b681941 100644 --- a/jitexpr/src/functions/regexp_extract.rs +++ b/jitexpr/src/functions/regexp_extract.rs @@ -355,19 +355,26 @@ mod tests { } #[test] - fn test_compile_group_zero_returns_full_match_without_capture_groups() { - for expression in [ - r#"(REGEXP_EXTRACT message "[a-z]+-\\d+")"#, - r#"(REGEXP_EXTRACT message "[a-z]+-\\d+" 0u64)"#, - ] { - let expression = ast::deserialize(expression).unwrap(); - let variable_types = HashMap::from([("message", VarType::Str)]); - let mut compiled = compile(&expression, &variable_types).unwrap(); - let input = [VariableValue::some("prefix user-123 suffix")]; - let output = unsafe { compiled.call(&input) }; + fn test_compile_omitted_group_defaults_to_full_match() { + let expression = ast::deserialize(r#"(REGEXP_EXTRACT message "[a-z]+-\\d+")"#).unwrap(); + let variable_types = HashMap::from([("message", VarType::Str)]); + let mut compiled = compile(&expression, &variable_types).unwrap(); + let input = [VariableValue::some("prefix user-123 suffix")]; + let output = unsafe { compiled.call(&input) }; - assert_eq!(unsafe { output.as_str() }, Some("user-123")); - } + assert_eq!(unsafe { output.as_str() }, Some("user-123")); + } + + #[test] + fn test_compile_group_zero_returns_full_match_without_capture_groups() { + let expression = + ast::deserialize(r#"(REGEXP_EXTRACT message "[a-z]+-\\d+" 0u64)"#).unwrap(); + let variable_types = HashMap::from([("message", VarType::Str)]); + let mut compiled = compile(&expression, &variable_types).unwrap(); + let input = [VariableValue::some("prefix user-123 suffix")]; + let output = unsafe { compiled.call(&input) }; + + assert_eq!(unsafe { output.as_str() }, Some("user-123")); } #[test]