@@ -20,39 +20,72 @@ public function __construct($name = null, array $data = [], $dataName = '')
20
20
parent ::__construct ($ name , $ data , $ dataName );
21
21
}
22
22
23
- public function testGetGroupedOpCodes ()
23
+ public function testGetGroupedOpCodesDefault ()
24
24
{
25
25
// Test with default options.
26
- $ sequenceMatcher = new SequenceMatcher ('54321ABXDE12345 ' , '54321ABxDE12345 ' );
26
+ $ sequenceMatcher = new SequenceMatcher (
27
+ '54321ABXDE12345 ' ,
28
+ '54321ABxDE12345 '
29
+ );
30
+
27
31
$ this ->assertEquals (
28
- [[['equal ' , 4 , 7 , 4 , 7 ], ['replace ' , 7 , 8 , 7 , 8 ], ['equal ' , 8 , 11 , 8 , 11 ]]],
32
+ [
33
+ [
34
+ ['equal ' , 4 , 7 , 4 , 7 ], ['replace ' , 7 , 8 , 7 , 8 ], ['equal ' , 8 , 11 , 8 , 11 ]
35
+ ]
36
+ ],
29
37
$ sequenceMatcher ->getGroupedOpCodes ()
30
38
);
39
+ }
31
40
41
+ public function testGetGroupedOpCodesTrimEqualFalse ()
42
+ {
32
43
// Test with trimEqual disabled.
33
- $ sequenceMatcher = new SequenceMatcher ('54321ABXDE12345 ' , '54321ABxDE12345 ' , ['trimEqual ' => false ]);
44
+ // First and last context lines of the sequences are included.
45
+ $ sequenceMatcher = new SequenceMatcher (
46
+ '54321ABXDE12345 ' ,
47
+ '54321ABxDE12345 ' ,
48
+ ['trimEqual ' => false ]
49
+ );
50
+
34
51
$ this ->assertEquals (
35
- [[['equal ' , 0 , 3 , 0 , 3 ]], [['equal ' , 4 , 7 , 4 , 7 ], ['replace ' , 7 , 8 , 7 , 8 ], ['equal ' , 8 , 11 , 8 , 11 ]]],
52
+ [
53
+ [['equal ' , 0 , 3 , 0 , 3 ]],
54
+ [['equal ' , 4 , 7 , 4 , 7 ], ['replace ' , 7 , 8 , 7 , 8 ], ['equal ' , 8 , 11 , 8 , 11 ]],
55
+ [['equal ' , 12 , 15 , 12 , 15 ]],
56
+ ],
36
57
$ sequenceMatcher ->getGroupedOpCodes ()
37
58
);
59
+ }
38
60
39
- // Test with ignoreWhitespace enabled.
61
+ public function testGetGroupedOpCodesIgnoreWhitespaceTrue ()
62
+ {
63
+ // Test with ignoreWhitespace enabled. Both sequences are considered to be the same.
40
64
// Note: The sequenceMatcher evaluates the string character by character. Option ignoreWhitespace will ignore
41
65
// if the difference if the character is a tab in one sequence and a space in the other.
42
66
$ sequenceMatcher = new SequenceMatcher (
43
67
"\t54321ABXDE12345 " ,
44
68
" 54321ABXDE12345 \t" ,
45
69
['ignoreWhitespace ' => true ]
46
70
);
71
+
47
72
$ this ->assertEquals (
48
- [[[ ' equal ' , 14 , 17 , 14 , 17 ]] ],
73
+ [],
49
74
$ sequenceMatcher ->getGroupedOpCodes ()
50
75
);
76
+ }
77
+
78
+ public function testGetGroupedOpCodesIgnoreCaseTrue ()
79
+ {
80
+ // Test with ignoreCase enabled. Both sequences are considered to be the same.
81
+ $ sequenceMatcher = new SequenceMatcher (
82
+ '54321ABXDE12345 ' ,
83
+ '54321ABxDE12345 ' ,
84
+ ['ignoreCase ' => true ]
85
+ );
51
86
52
- // Test with ignoreCase enabled.
53
- $ sequenceMatcher = new SequenceMatcher ('54321ABXDE12345 ' , '54321ABxDE12345 ' , ['ignoreCase ' => true ]);
54
87
$ this ->assertEquals (
55
- [[[ ' equal ' , 12 , 15 , 12 , 15 ]] ],
88
+ [],
56
89
$ sequenceMatcher ->getGroupedOpCodes ()
57
90
);
58
91
}
0 commit comments