Skip to content

Commit e06c653

Browse files
committed
Last line patch tests
1 parent 8509bc6 commit e06c653

File tree

1 file changed

+83
-1
lines changed

1 file changed

+83
-1
lines changed

test/diffTest.js

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const VERBOSE = false;
22

33
var assert = require('assert'),
4-
diff = require('../diff');
4+
diff = require('../diff');
55

66
function log() {
77
VERBOSE && console.log.apply(console, arguments);
@@ -128,6 +128,88 @@ exports['Line diffs'] = function() {
128128
"Line whitespace diffResult Value");
129129
};
130130

131+
// Patch creation with diff at EOF
132+
exports['lastLineChanged'] = function() {
133+
assert.eql(
134+
'Index: test\n'
135+
+ '===================================================================\n'
136+
+ '--- test\theader1\n'
137+
+ '+++ test\theader2\n'
138+
+ '@@ -1,3 +1,4 @@\n'
139+
+ ' line2\n'
140+
+ ' line3\n'
141+
+ '+line4\n'
142+
+ ' line5\n',
143+
diff.createPatch('test', 'line2\nline3\nline5\n', 'line2\nline3\nline4\nline5\n', 'header1', 'header2'));
144+
145+
assert.eql(
146+
'Index: test\n'
147+
+ '===================================================================\n'
148+
+ '--- test\theader1\n'
149+
+ '+++ test\theader2\n'
150+
+ '@@ -1,3 +1,4 @@\n'
151+
+ ' line2\n'
152+
+ ' line3\n'
153+
+ ' line4\n'
154+
+ '+line5\n',
155+
diff.createPatch('test', 'line2\nline3\nline4\n', 'line2\nline3\nline4\nline5\n', 'header1', 'header2'));
156+
157+
assert.eql(
158+
'Index: test\n'
159+
+ '===================================================================\n'
160+
+ '--- test\theader1\n'
161+
+ '+++ test\theader2\n'
162+
+ '@@ -1,4 +1,4 @@\n'
163+
+ ' line1\n'
164+
+ ' line2\n'
165+
+ ' line3\n'
166+
+ '+line4\n'
167+
+ '\\ No newline at end of file\n'
168+
+ '-line4\n',
169+
diff.createPatch('test', 'line1\nline2\nline3\nline4\n', 'line1\nline2\nline3\nline4', 'header1', 'header2'));
170+
171+
assert.eql(
172+
'Index: test\n'
173+
+ '===================================================================\n'
174+
+ '--- test\theader1\n'
175+
+ '+++ test\theader2\n'
176+
+ '@@ -1,4 +1,4 @@\n'
177+
+ ' line1\n'
178+
+ ' line2\n'
179+
+ ' line3\n'
180+
+ '+line4\n'
181+
+ '-line4\n'
182+
+ '\\ No newline at end of file\n',
183+
diff.createPatch('test', 'line1\nline2\nline3\nline4', 'line1\nline2\nline3\nline4\n', 'header1', 'header2'));
184+
185+
assert.eql(
186+
'Index: test\n'
187+
+ '===================================================================\n'
188+
+ '--- test\theader1\n'
189+
+ '+++ test\theader2\n'
190+
+ '@@ -1,4 +1,4 @@\n'
191+
+ ' line1\n'
192+
+ ' line2\n'
193+
+ ' line3\n'
194+
+ '+line44\n'
195+
+ '-line4\n',
196+
diff.createPatch('test', 'line1\nline2\nline3\nline4\n', 'line1\nline2\nline3\nline44\n', 'header1', 'header2'));
197+
198+
assert.eql(
199+
'Index: test\n'
200+
+ '===================================================================\n'
201+
+ '--- test\theader1\n'
202+
+ '+++ test\theader2\n'
203+
+ '@@ -1,4 +1,5 @@\n'
204+
+ ' line1\n'
205+
+ ' line2\n'
206+
+ ' line3\n'
207+
+ '+line44\n'
208+
+ '+line5\n'
209+
+ '-line4\n',
210+
diff.createPatch('test', 'line1\nline2\nline3\nline4\n', 'line1\nline2\nline3\nline44\nline5\n', 'header1', 'header2'));
211+
};
212+
131213
exports['Large Test'] = function() {
132214
var random = 42;
133215
var mult = 134775813, range = Math.pow(2, 32);

0 commit comments

Comments
 (0)