Permalink
Browse files

Copy 160kb string test from C# to other languages

  • Loading branch information...
NeilFraser committed Jul 12, 2018
1 parent d9b6d33 commit b750d263fa1f4a4c37c97196ff2bc05a0aa2006b
@@ -462,6 +462,18 @@ void testDiffDelta() {
// Convert delta string into a diff.
Expect.listEquals(diffs, dmp.diff_fromDelta('', delta), 'diff_fromDelta: Unchanged characters.');
// 160 kb string.
var a = 'abcdefghij';
for (var i = 0; i < 14; i++) {
a += a;
}
diffs = [new Diff(Operation.insert, a)];
delta = dmp.diff_toDelta(diffs);
Expect.equals('+' + a, delta, 'diff_toDelta: 160kb string.');
// Convert delta string into a diff.
Expect.listEquals(diffs, dmp.diff_fromDelta('', delta), 'diff_fromDelta: 160kb string.');
}
void testDiffXIndex() {
@@ -434,6 +434,18 @@ public static void testDiffDelta() {
// Convert delta string into a diff.
assertEquals("diff_fromDelta: Unchanged characters.", diffs, dmp.diff_fromDelta("", delta));
// 160 kb string.
String a = "abcdefghij";
for (int i = 0; i < 14; i++) {
a += a;
}
diffs = diffList(new Diff(INSERT, a));
delta = dmp.diff_toDelta(diffs);
assertEquals("diff_toDelta: 160kb string.", "+" + a, delta);
// Convert delta string into a diff.
assertEquals("diff_fromDelta: 160kb string.", diffs, dmp.diff_fromDelta("", delta));
}
public static void testDiffXIndex() {
@@ -502,6 +502,18 @@ function testDiffDelta() {
// Convert delta string into a diff.
assertEquivalent(diffs, dmp.diff_fromDelta('', delta));
// 160 kb string.
var a = 'abcdefghij';
for (var i = 0; i < 14; i++) {
a += a;
}
diffs = [[DIFF_INSERT, a]];
delta = dmp.diff_toDelta(diffs);
assertEquals('+' + a, delta);
// Convert delta string into a diff.
assertEquivalent(diffs, dmp.diff_fromDelta('', delta));
}
function testDiffXIndex() {
@@ -550,6 +550,15 @@ function testDiffDelta()
-- Convert delta string into a diff.
assertEquivalent(diffs, dmp.diff_fromDelta('', delta))
-- 160 kb string.
local a = string.rep('abcdefghij', 16384)
diffs = {{DIFF_INSERT, a}};
delta = dmp.diff_toDelta(diffs);
assertEquals('+' .. a, delta);
-- Convert delta string into a diff.
assertEquivalent(diffs, dmp.diff_fromDelta('', delta));
end
function testDiffXIndex()
@@ -765,6 +765,22 @@ - (void)test_diff_deltaTest {
expectedResult = [dmp diff_fromDeltaWithText:@"" andDelta:delta error:NULL];
XCTAssertEqualObjects(diffs, expectedResult, @"diff_fromDelta: Unchanged characters. Convert delta string into a diff.");
// 160 kb string.
NSString *a = @"abcdefghij";
NSMutableString *aMutable = [NSMutableString stringWithString:a];
for (int i = 0; i < 14; i++) {
[aMutable appendString:aMutable];
}
a = aMutable;
diffs = [NSMutableArray arrayWithObject:
[Diff diffWithOperation:DIFF_INSERT andText:a]];
delta = [dmp diff_toDelta:diffs];
XCTAssertEqualObjects([@"+" stringByAppendingString:a], delta, @"diff_toDelta: 160kb string.");
// Convert delta string into a diff.
expectedResult = [dmp diff_fromDeltaWithText:@"" andDelta:delta error:NULL];
XCTAssertEqualObjects(diffs, expectedResult, @"diff_fromDelta: 160kb string. Convert delta string into a diff.");
[dmp release];
}
@@ -452,6 +452,17 @@ def testDiffDelta(self):
# Convert delta string into a diff.
self.assertEquals(diffs, self.dmp.diff_fromDelta("", delta))
# 160 kb string.
a = "abcdefghij"
for i in range(14):
a += a
diffs = [(self.dmp.DIFF_INSERT, a)]
delta = self.dmp.diff_toDelta(diffs);
self.assertEquals('+' + a, delta);
# Convert delta string into a diff.
self.assertEquals(diffs, self.dmp.diff_fromDelta("", delta));
def testDiffXIndex(self):
# Translate a location in text1 to text2.
self.assertEquals(5, self.dmp.diff_xIndex([(self.dmp.DIFF_DELETE, "a"), (self.dmp.DIFF_INSERT, "1234"), (self.dmp.DIFF_EQUAL, "xyz")], 2))
@@ -455,6 +455,17 @@ def testDiffDelta(self):
# Convert delta string into a diff.
self.assertEqual(diffs, self.dmp.diff_fromDelta("", delta))
# 160 kb string.
a = "abcdefghij"
for i in range(14):
a += a
diffs = [(self.dmp.DIFF_INSERT, a)]
delta = self.dmp.diff_toDelta(diffs);
self.assertEqual('+' + a, delta);
# Convert delta string into a diff.
self.assertEqual(diffs, self.dmp.diff_fromDelta("", delta));
def testDiffXIndex(self):
# Translate a location in text1 to text2.
self.assertEqual(5, self.dmp.diff_xIndex([(self.dmp.DIFF_DELETE, "a"), (self.dmp.DIFF_INSERT, "1234"), (self.dmp.DIFF_EQUAL, "xyz")], 2))

0 comments on commit b750d26

Please sign in to comment.