@@ -172,11 +172,11 @@ - (void)test_diff_linesToCharsTest {
172172 NSMutableString *lines = [NSMutableString string ];
173173 NSMutableString *chars = [NSMutableString string ];
174174 NSString *currentLine;
175- for (unichar x = 1 ; x < n + 1 ; x ++) {
176- currentLine = [NSString stringWithFormat: @" %d \n " , (int )x ];
175+ for (unichar i = 1 ; i < n + 1 ; i ++) {
176+ currentLine = [NSString stringWithFormat: @" %d \n " , (int )i ];
177177 [tmpVector addObject: currentLine];
178178 [lines appendString: currentLine];
179- [chars appendString: [NSString stringWithFormat: @" %C " , x ]];
179+ [chars appendString: [NSString stringWithFormat: @" %C " , i ]];
180180 }
181181 XCTAssertEqual ((NSUInteger )n, tmpVector.count , @" More than 256 #1." );
182182 XCTAssertEqual ((NSUInteger )n, chars.length , @" More than 256 #2." );
@@ -212,11 +212,11 @@ - (void)test_diff_charsToLinesTest {
212212 NSMutableString *lines = [NSMutableString string ];
213213 NSMutableString *chars = [NSMutableString string ];
214214 NSString *currentLine;
215- for (unichar x = 1 ; x < n + 1 ; x ++) {
216- currentLine = [NSString stringWithFormat: @" %d \n " , (int )x ];
215+ for (unichar i = 1 ; i < n + 1 ; i ++) {
216+ currentLine = [NSString stringWithFormat: @" %d \n " , (int )i ];
217217 [tmpVector addObject: currentLine];
218218 [lines appendString: currentLine];
219- [chars appendString: [NSString stringWithFormat: @" %C " , x ]];
219+ [chars appendString: [NSString stringWithFormat: @" %C " , i ]];
220220 }
221221 XCTAssertEqual ((NSUInteger )n, tmpVector.count , @" More than 256 #1." );
222222 XCTAssertEqual ((NSUInteger )n, chars.length , @" More than 256 #2." );
@@ -225,6 +225,19 @@ - (void)test_diff_charsToLinesTest {
225225 [dmp diff_chars: diffs toLines: tmpVector];
226226 XCTAssertEqualObjects ([NSArray arrayWithObject: [Diff diffWithOperation: DIFF_DELETE andText: lines]], diffs, @" More than 256 #3." );
227227
228+ // More than 65536 to verify any 16-bit limitation.
229+ lines = [NSMutableString string ];
230+ for (int i = 1 ; i < 66000 ; i++) {
231+ currentLine = [NSString stringWithFormat: @" %d \n " , i];
232+ [lines appendString: currentLine];
233+ }
234+ NSArray *result;
235+ result = [dmp diff_linesToCharsForFirstString: lines andSecondString: @" " ];
236+ diffs = [NSArray arrayWithObject: [Diff diffWithOperation: DIFF_INSERT andText: result[0 ]]];
237+ [dmp diff_chars: diffs toLines: result[2 ]];
238+ Diff *myDiff = diffs.firstObject ;
239+ XCTAssertEqualObjects (lines, myDiff.text , @" More than 65536." );
240+
228241 [dmp release ];
229242}
230243
@@ -859,7 +872,7 @@ - (void)test_diff_mainTest {
859872 NSMutableString *aMutable = [NSMutableString stringWithString: a];
860873 NSMutableString *bMutable = [NSMutableString stringWithString: b];
861874 // Increase the text lengths by 1024 times to ensure a timeout.
862- for (int x = 0 ; x < 10 ; x ++) {
875+ for (int i = 0 ; i < 10 ; i ++) {
863876 [aMutable appendString: aMutable];
864877 [bMutable appendString: bMutable];
865878 }
0 commit comments