@@ -20,39 +20,72 @@ public function __construct($name = null, array $data = [], $dataName = '')
2020 parent ::__construct ($ name , $ data , $ dataName );
2121 }
2222
23- public function testGetGroupedOpCodes ()
23+ public function testGetGroupedOpCodesDefault ()
2424 {
2525 // Test with default options.
26- $ sequenceMatcher = new SequenceMatcher ('54321ABXDE12345 ' , '54321ABxDE12345 ' );
26+ $ sequenceMatcher = new SequenceMatcher (
27+ '54321ABXDE12345 ' ,
28+ '54321ABxDE12345 '
29+ );
30+
2731 $ 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+ ],
2937 $ sequenceMatcher ->getGroupedOpCodes ()
3038 );
39+ }
3140
41+ public function testGetGroupedOpCodesTrimEqualFalse ()
42+ {
3243 // 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+
3451 $ 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+ ],
3657 $ sequenceMatcher ->getGroupedOpCodes ()
3758 );
59+ }
3860
39- // Test with ignoreWhitespace enabled.
61+ public function testGetGroupedOpCodesIgnoreWhitespaceTrue ()
62+ {
63+ // Test with ignoreWhitespace enabled. Both sequences are considered to be the same.
4064 // Note: The sequenceMatcher evaluates the string character by character. Option ignoreWhitespace will ignore
4165 // if the difference if the character is a tab in one sequence and a space in the other.
4266 $ sequenceMatcher = new SequenceMatcher (
4367 "\t54321ABXDE12345 " ,
4468 " 54321ABXDE12345 \t" ,
4569 ['ignoreWhitespace ' => true ]
4670 );
71+
4772 $ this ->assertEquals (
48- [[[ ' equal ' , 14 , 17 , 14 , 17 ]] ],
73+ [],
4974 $ sequenceMatcher ->getGroupedOpCodes ()
5075 );
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+ );
5186
52- // Test with ignoreCase enabled.
53- $ sequenceMatcher = new SequenceMatcher ('54321ABXDE12345 ' , '54321ABxDE12345 ' , ['ignoreCase ' => true ]);
5487 $ this ->assertEquals (
55- [[[ ' equal ' , 12 , 15 , 12 , 15 ]] ],
88+ [],
5689 $ sequenceMatcher ->getGroupedOpCodes ()
5790 );
5891 }
0 commit comments