From 89d44c0fc62012e941822f00ea9289bbee41fd8f Mon Sep 17 00:00:00 2001 From: Alex Bezzubov Date: Sat, 20 May 2023 23:25:07 +0200 Subject: [PATCH] test: add a case of 'general newilne' AKA \R syntax Checking support for multiple \R, the "general newline" shorthand https://github.com/kkos/oniguruma/blob/3bbb3d65c65350bfd941129592cb390aadedb25a/doc/SYNTAX.md#23-onig_syn_op2_esc_capital_r_general_newline-enable-r --- regex_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/regex_test.go b/regex_test.go index 9c53195..81978be 100644 --- a/regex_test.go +++ b/regex_test.go @@ -606,6 +606,15 @@ var findTests = []FindTest{ 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36), }, + + // https://github.com/kkos/oniguruma/blob/2a25d8c2c4699c57f4d456ccd13149c0c714723d/test/test_back.c#LL629C1-L631C25 + {"\\R", "\r\n", build(1, 0, 2)}, + {"\\R", "\r", build(1, 0, 1)}, + {"\\R", "\n", build(1, 0, 1)}, + + {`b\R.*\R`, "ab\nc\n", build(1, 1, 5)}, + // equivalent, from Linguist dataset + {`^\s*BEGIN\R\s*.*\R`, "\tBEGIN\n\tMultiUse = -1 'True\n", build(1, 0, 29)}, } // build is a helper to construct a [][]int by extracting n sequences from x.