@@ -47,6 +47,13 @@ public void testMvfindWithLastElementMatch() {
4747 assertEquals (2 , result );
4848 }
4949
50+ @ Test
51+ public void testMvfindReturnsFirstMatch () {
52+ List <Object > array = Arrays .asList ("test1" , "test2" , "test3" );
53+ Object result = MVFindFunctionImpl .eval (array , "test" );
54+ assertEquals (0 , result ); // Returns first match, not all
55+ }
56+
5057 // Null handling tests
5158
5259 @ Test
@@ -81,13 +88,6 @@ public void testMvfindWithNullElementInArray() {
8188 assertEquals (2 , result );
8289 }
8390
84- @ Test
85- public void testMvfindWithAllNullElements () {
86- List <Object > array = Arrays .asList (null , null , null );
87- Object result = MVFindFunctionImpl .eval (array , "pattern" );
88- assertNull (result );
89- }
90-
9191 // Edge cases
9292
9393 @ Test
@@ -101,14 +101,6 @@ public void testMvfindWithEmptyArray() {
101101 public void testMvfindWithEmptyStringPattern () {
102102 List <Object > array = Arrays .asList ("apple" , "banana" );
103103 Object result = MVFindFunctionImpl .eval (array , "" );
104- // Empty pattern matches everything (finds at position 0 in "apple")
105- assertEquals (0 , result );
106- }
107-
108- @ Test
109- public void testMvfindWithEmptyStringElement () {
110- List <Object > array = Arrays .asList ("apple" , "" , "banana" );
111- Object result = MVFindFunctionImpl .eval (array , "" );
112104 assertEquals (0 , result ); // Empty pattern matches first element
113105 }
114106
@@ -121,27 +113,13 @@ public void testMvfindWithSingleElementArray() {
121113
122114 // Regex pattern tests
123115
124- @ Test
125- public void testMvfindWithPartialMatch () {
126- List <Object > array = Arrays .asList ("apple" , "banana" , "apricot" );
127- Object result = MVFindFunctionImpl .eval (array , "ban" );
128- assertEquals (1 , result );
129- }
130-
131116 @ Test
132117 public void testMvfindWithWildcardPattern () {
133118 List <Object > array = Arrays .asList ("apple" , "banana" , "apricot" );
134119 Object result = MVFindFunctionImpl .eval (array , "ban.*" );
135120 assertEquals (1 , result );
136121 }
137122
138- @ Test
139- public void testMvfindWithDotPlus () {
140- List <Object > array = Arrays .asList ("a" , "ab" , "abc" );
141- Object result = MVFindFunctionImpl .eval (array , "a.+" );
142- assertEquals (1 , result ); // Matches "ab"
143- }
144-
145123 @ Test
146124 public void testMvfindWithCharacterClass () {
147125 List <Object > array = Arrays .asList ("error123" , "info" , "error456" );
@@ -157,10 +135,10 @@ public void testMvfindWithDigitClass() {
157135 }
158136
159137 @ Test
160- public void testMvfindWithWordBoundary () {
161- List <Object > array = Arrays .asList ("hello world " , "helloworld " , "hello " );
162- Object result = MVFindFunctionImpl .eval (array , "\\ bhello \\ b " );
163- assertEquals (0 , result );
138+ public void testMvfindWithCaseInsensitiveFlag () {
139+ List <Object > array = Arrays .asList ("Apple " , "Banana " , "Cherry " );
140+ Object result = MVFindFunctionImpl .eval (array , "(?i)banana " );
141+ assertEquals (1 , result );
164142 }
165143
166144 @ Test
@@ -177,64 +155,6 @@ public void testMvfindWithAnchorEnd() {
177155 assertEquals (0 , result );
178156 }
179157
180- @ Test
181- public void testMvfindWithAlternation () {
182- List <Object > array = Arrays .asList ("cat" , "dog" , "bird" );
183- Object result = MVFindFunctionImpl .eval (array , "dog|cat" );
184- assertEquals (0 , result ); // Finds "cat" first
185- }
186-
187- @ Test
188- public void testMvfindWithOptionalQuantifier () {
189- List <Object > array = Arrays .asList ("color" , "colour" , "colors" );
190- Object result = MVFindFunctionImpl .eval (array , "colou?r" );
191- assertEquals (0 , result );
192- }
193-
194- @ Test
195- public void testMvfindWithCaseInsensitiveFlag () {
196- List <Object > array = Arrays .asList ("Apple" , "Banana" , "Cherry" );
197- Object result = MVFindFunctionImpl .eval (array , "(?i)banana" );
198- assertEquals (1 , result );
199- }
200-
201- @ Test
202- public void testMvfindWithNegatedCharacterClass () {
203- List <Object > array = Arrays .asList ("abc123" , "abc" , "123" );
204- Object result = MVFindFunctionImpl .eval (array , "[^0-9]+" );
205- assertEquals (0 , result ); // Matches "abc123" (has non-digits)
206- }
207-
208- @ Test
209- public void testMvfindWithEscapedSpecialChars () {
210- List <Object > array = Arrays .asList ("test.log" , "test-log" , "testlog" );
211- Object result = MVFindFunctionImpl .eval (array , "test\\ .log" );
212- assertEquals (0 , result );
213- }
214-
215- @ Test
216- public void testMvfindWithGroup () {
217- List <Object > array = Arrays .asList ("abc" , "ababab" , "abab" );
218- Object result = MVFindFunctionImpl .eval (array , "(ab)+" );
219- assertEquals (0 , result );
220- }
221-
222- // Multiple matches - should return first
223-
224- @ Test
225- public void testMvfindReturnsFirstMatch () {
226- List <Object > array = Arrays .asList ("apple" , "apricot" , "application" );
227- Object result = MVFindFunctionImpl .eval (array , "app" );
228- assertEquals (0 , result ); // Returns first match, not all
229- }
230-
231- @ Test
232- public void testMvfindWithMultipleMatchingElements () {
233- List <Object > array = Arrays .asList ("test1" , "test2" , "test3" );
234- Object result = MVFindFunctionImpl .eval (array , "test" );
235- assertEquals (0 , result ); // Returns first
236- }
237-
238158 // Case sensitivity
239159
240160 @ Test
@@ -244,13 +164,6 @@ public void testMvfindIsCaseSensitiveByDefault() {
244164 assertNull (result ); // No match because case-sensitive
245165 }
246166
247- @ Test
248- public void testMvfindWithExactCaseMatch () {
249- List <Object > array = Arrays .asList ("Apple" , "banana" , "Cherry" );
250- Object result = MVFindFunctionImpl .eval (array , "Apple" );
251- assertEquals (0 , result );
252- }
253-
254167 // Invalid regex patterns
255168
256169 @ Test
@@ -263,16 +176,6 @@ public void testMvfindWithInvalidRegex() {
263176 });
264177 }
265178
266- @ Test
267- public void testMvfindWithUnclosedGroup () {
268- List <Object > array = Arrays .asList ("test" );
269- assertThrows (
270- RuntimeException .class ,
271- () -> {
272- MVFindFunctionImpl .eval (array , "(unclosed" );
273- });
274- }
275-
276179 // Type conversion tests
277180
278181 @ Test
@@ -295,93 +198,4 @@ public void testMvfindWithBooleanElements() {
295198 Object result = MVFindFunctionImpl .eval (array , "false" );
296199 assertEquals (1 , result );
297200 }
298-
299- @ Test
300- public void testMvfindNumericPattern () {
301- List <Object > array = Arrays .asList ("test123" , "test456" , "test" );
302- Object result = MVFindFunctionImpl .eval (array , "\\ d{3}" );
303- assertEquals (0 , result );
304- }
305-
306- // Special regex features
307-
308- @ Test
309- public void testMvfindWithLookahead () {
310- List <Object > array = Arrays .asList ("test123" , "test" , "test456" );
311- Object result = MVFindFunctionImpl .eval (array , "test(?=\\ d)" );
312- assertEquals (0 , result );
313- }
314-
315- @ Test
316- public void testMvfindWithLookbehind () {
317- List <Object > array = Arrays .asList ("pretest" , "test" , "posttest" );
318- Object result = MVFindFunctionImpl .eval (array , "(?<=pre)test" );
319- assertEquals (0 , result );
320- }
321-
322- @ Test
323- public void testMvfindWithNonCapturingGroup () {
324- List <Object > array = Arrays .asList ("apple" , "application" , "apply" );
325- Object result = MVFindFunctionImpl .eval (array , "app(?:le|ly)" );
326- assertEquals (0 , result );
327- }
328-
329- // Edge cases with whitespace
330-
331- @ Test
332- public void testMvfindWithWhitespace () {
333- List <Object > array = Arrays .asList ("hello world" , "hello" , "world" );
334- Object result = MVFindFunctionImpl .eval (array , "hello\\ s+world" );
335- assertEquals (0 , result );
336- }
337-
338- @ Test
339- public void testMvfindWithLeadingTrailingSpaces () {
340- List <Object > array = Arrays .asList (" test " , "test" , " test" );
341- Object result = MVFindFunctionImpl .eval (array , "^\\ s+test" );
342- assertEquals (0 , result );
343- }
344-
345- @ Test
346- public void testMvfindWithTab () {
347- List <Object > array = Arrays .asList ("hello\t world" , "hello world" );
348- Object result = MVFindFunctionImpl .eval (array , "hello\\ tworld" );
349- assertEquals (0 , result );
350- }
351-
352- // Unicode and special characters
353-
354- @ Test
355- public void testMvfindWithUnicodeCharacters () {
356- List <Object > array = Arrays .asList ("café" , "resume" , "naïve" );
357- Object result = MVFindFunctionImpl .eval (array , "café" );
358- assertEquals (0 , result );
359- }
360-
361- @ Test
362- public void testMvfindWithSpecialCharacters () {
363- List <Object > array = Arrays .asList ("hello@world" , "hello#world" , "hello$world" );
364- Object result = MVFindFunctionImpl .eval (array , "hello@world" );
365- assertEquals (0 , result );
366- }
367-
368- // Boundary testing
369-
370- @ Test
371- public void testMvfindWithVeryLongArray () {
372- Object [] elements = new Object [1000 ];
373- for (int i = 0 ; i < 1000 ; i ++) {
374- elements [i ] = "element" + i ;
375- }
376- List <Object > array = Arrays .asList (elements );
377- Object result = MVFindFunctionImpl .eval (array , "element500" );
378- assertEquals (500 , result );
379- }
380-
381- @ Test
382- public void testMvfindWithVeryLongPattern () {
383- List <Object > array = Arrays .asList ("a" .repeat (1000 ));
384- Object result = MVFindFunctionImpl .eval (array , "a{1000}" );
385- assertEquals (0 , result );
386- }
387201}
0 commit comments