Permalink
Browse files

Last line patch tests

  • Loading branch information...
kpdecker committed Dec 24, 2011
1 parent 8509bc6 commit e06c65386138e35ba36d059be68d52a47016c01c
Showing with 83 additions and 1 deletion.
  1. +83 −1 test/diffTest.js
View
@@ -1,7 +1,7 @@
const VERBOSE = false;
var assert = require('assert'),
- diff = require('../diff');
+ diff = require('../diff');
function log() {
VERBOSE && console.log.apply(console, arguments);
@@ -128,6 +128,88 @@ exports['Line diffs'] = function() {
"Line whitespace diffResult Value");
};
+// Patch creation with diff at EOF
+exports['lastLineChanged'] = function() {
+ assert.eql(
+ 'Index: test\n'
+ + '===================================================================\n'
+ + '--- test\theader1\n'
+ + '+++ test\theader2\n'
+ + '@@ -1,3 +1,4 @@\n'
+ + ' line2\n'
+ + ' line3\n'
+ + '+line4\n'
+ + ' line5\n',
+ diff.createPatch('test', 'line2\nline3\nline5\n', 'line2\nline3\nline4\nline5\n', 'header1', 'header2'));
+
+ assert.eql(
+ 'Index: test\n'
+ + '===================================================================\n'
+ + '--- test\theader1\n'
+ + '+++ test\theader2\n'
+ + '@@ -1,3 +1,4 @@\n'
+ + ' line2\n'
+ + ' line3\n'
+ + ' line4\n'
+ + '+line5\n',
+ diff.createPatch('test', 'line2\nline3\nline4\n', 'line2\nline3\nline4\nline5\n', 'header1', 'header2'));
+
+ assert.eql(
+ 'Index: test\n'
+ + '===================================================================\n'
+ + '--- test\theader1\n'
+ + '+++ test\theader2\n'
+ + '@@ -1,4 +1,4 @@\n'
+ + ' line1\n'
+ + ' line2\n'
+ + ' line3\n'
+ + '+line4\n'
+ + '\\ No newline at end of file\n'
+ + '-line4\n',
+ diff.createPatch('test', 'line1\nline2\nline3\nline4\n', 'line1\nline2\nline3\nline4', 'header1', 'header2'));
+
+ assert.eql(
+ 'Index: test\n'
+ + '===================================================================\n'
+ + '--- test\theader1\n'
+ + '+++ test\theader2\n'
+ + '@@ -1,4 +1,4 @@\n'
+ + ' line1\n'
+ + ' line2\n'
+ + ' line3\n'
+ + '+line4\n'
+ + '-line4\n'
+ + '\\ No newline at end of file\n',
+ diff.createPatch('test', 'line1\nline2\nline3\nline4', 'line1\nline2\nline3\nline4\n', 'header1', 'header2'));
+
+ assert.eql(
+ 'Index: test\n'
+ + '===================================================================\n'
+ + '--- test\theader1\n'
+ + '+++ test\theader2\n'
+ + '@@ -1,4 +1,4 @@\n'
+ + ' line1\n'
+ + ' line2\n'
+ + ' line3\n'
+ + '+line44\n'
+ + '-line4\n',
+ diff.createPatch('test', 'line1\nline2\nline3\nline4\n', 'line1\nline2\nline3\nline44\n', 'header1', 'header2'));
+
+ assert.eql(
+ 'Index: test\n'
+ + '===================================================================\n'
+ + '--- test\theader1\n'
+ + '+++ test\theader2\n'
+ + '@@ -1,4 +1,5 @@\n'
+ + ' line1\n'
+ + ' line2\n'
+ + ' line3\n'
+ + '+line44\n'
+ + '+line5\n'
+ + '-line4\n',
+ diff.createPatch('test', 'line1\nline2\nline3\nline4\n', 'line1\nline2\nline3\nline44\nline5\n', 'header1', 'header2'));
+};
+
exports['Large Test'] = function() {
var random = 42;
var mult = 134775813, range = Math.pow(2, 32);

0 comments on commit e06c653

Please sign in to comment.