diff --git a/core/text/regex/common/common.odin b/core/text/regex/common/common.odin index f53f043a1..f401658cb 100644 --- a/core/text/regex/common/common.odin +++ b/core/text/regex/common/common.odin @@ -2,7 +2,7 @@ package regex_common // VM limitations -MAX_CAPTURE_GROUPS :: 10 +MAX_CAPTURE_GROUPS :: max(#config(ODIN_REGEX_MAX_CAPTURE_GROUPS, 10), 10) MAX_PROGRAM_SIZE :: int(max(i16)) MAX_CLASSES :: int(max(u8)) diff --git a/tests/core/text/regex/test_core_text_regex.odin b/tests/core/text/regex/test_core_text_regex.odin index 0bd1ff288..74a0b8cf7 100644 --- a/tests/core/text/regex/test_core_text_regex.odin +++ b/tests/core/text/regex/test_core_text_regex.odin @@ -276,9 +276,58 @@ test_optional_capture_group :: proc(t: ^testing.T) { @test test_max_capture_groups :: proc(t: ^testing.T) { - EXPR :: "(1)(2)(3)(4)(5)(6)(7)(8)(9)" - check_expression(t, EXPR, "123456789", "123456789", - "1", "2", "3", "4", "5", "6", "7", "8", "9") + sb_pattern := strings.builder_make() + sb_haystack := strings.builder_make() + expected_captures: [dynamic]string + defer { + strings.builder_destroy(&sb_pattern) + strings.builder_destroy(&sb_haystack) + delete(expected_captures) + } + + w_pattern := strings.to_writer(&sb_pattern) + w_haystack := strings.to_writer(&sb_haystack) + + // The full expression capture, capture 0: + for i in 1..