This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28e5e59
commit 1b99c81
Showing
7 changed files
with
6,712 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<!-- | ||
Test Harness for diff_match_patch.js (compiled from diff_match_patch.ts) | ||
Copyright 2018 The diff-match-patch Authors. | ||
https://github.com/google/diff-match-patch | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<html> | ||
<head> | ||
<TITLE>Test harness for diff_match_patch.js (compiled from diff_match_patch.ts)</TITLE> | ||
<script type="text/javascript" src="../diff_match_patch.js"></script> | ||
<script type="text/javascript" src="diff_match_patch_test.js"></script> | ||
|
||
<script type="text/javascript"> | ||
// Counters for unit test results. | ||
var test_good = 0; | ||
var test_bad = 0; | ||
|
||
// If expected and actual are the identical, print 'Ok', otherwise 'Fail!' | ||
function assertEquals(msg, expected, actual) { | ||
if (typeof actual == 'undefined') { | ||
// msg is optional. | ||
actual = expected; | ||
expected = msg; | ||
msg = 'Expected: \'' + expected + '\' Actual: \'' + actual + '\''; | ||
} | ||
if (expected === actual) { | ||
document.write('<FONT COLOR="#009900">Ok</FONT><BR>'); | ||
test_good++; | ||
return true; | ||
} else { | ||
document.write('<FONT COLOR="#990000"><BIG>Fail!</BIG></FONT><BR>'); | ||
msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | ||
document.write('<code>' + msg + '</code><BR>'); | ||
test_bad++; | ||
return false; | ||
} | ||
} | ||
|
||
function assertTrue(msg, actual) { | ||
if (typeof actual == 'undefined') { | ||
// msg is optional. | ||
actual = msg; | ||
return assertEquals(true, actual); | ||
} else { | ||
return assertEquals(msg, true, actual); | ||
} | ||
} | ||
|
||
function assertFalse(msg, actual) { | ||
if (typeof actual == 'undefined') { | ||
// msg is optional. | ||
actual = msg; | ||
return assertEquals(false, actual); | ||
} else { | ||
return assertEquals(msg, false, actual); | ||
} | ||
} | ||
|
||
function runTests() { | ||
for (var x = 0; x < tests.length; x++) { | ||
document.write('<H3>' + tests[x] + ':</H3>'); | ||
eval(tests[x] + '()'); | ||
} | ||
} | ||
|
||
var tests = [ | ||
'testDiffCommonPrefix', | ||
'testDiffCommonSuffix', | ||
'testDiffCommonOverlap', | ||
'testDiffHalfMatch', | ||
'testDiffLinesToChars', | ||
'testDiffCharsToLines', | ||
'testDiffCleanupMerge', | ||
'testDiffCleanupSemanticLossless', | ||
'testDiffCleanupSemantic', | ||
'testDiffCleanupEfficiency', | ||
'testDiffPrettyHtml', | ||
'testDiffText', | ||
'testDiffDelta', | ||
'testDiffXIndex', | ||
'testDiffLevenshtein', | ||
'testDiffBisect', | ||
'testDiffMain', | ||
|
||
'testMatchAlphabet', | ||
'testMatchBitap', | ||
'testMatchMain', | ||
|
||
'testPatchObj', | ||
'testPatchFromText', | ||
'testPatchToText', | ||
'testPatchAddContext', | ||
'testPatchMake', | ||
'testPatchSplitMax', | ||
'testPatchAddPadding', | ||
'testPatchApply']; | ||
|
||
</script> | ||
</head> | ||
<body> | ||
<H1>Test harness for diff_match_patch.js (compiled from diff_match_patch.ts)</H1> | ||
|
||
<P>If debugging errors, start with the first reported error, | ||
subsequent tests often rely on earlier ones.</P> | ||
|
||
<script type="text/javascript"> | ||
var startTime = (new Date()).getTime(); | ||
runTests(); | ||
var endTime = (new Date()).getTime(); | ||
document.write('<H3>Done.</H3>'); | ||
document.write('<P>Tests passed: ' + test_good + '<BR>Tests failed: ' + test_bad + '</P>'); | ||
document.write('<P>Total time: ' + (endTime - startTime) + ' ms</P>'); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.