Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Unified Diff: pkg/analysis_server/test/services/correction/strings_test.dart

Issue 1849843002: Rework computing simple strings difference. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/strings.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/correction/strings_test.dart
diff --git a/pkg/analysis_server/test/services/correction/strings_test.dart b/pkg/analysis_server/test/services/correction/strings_test.dart
index 3fb37fbffbd0deb956868bbd36c3765e2b32cbbf..a5b4779b48c9f06717c76c020116675e00176770 100644
--- a/pkg/analysis_server/test/services/correction/strings_test.dart
+++ b/pkg/analysis_server/test/services/correction/strings_test.dart
@@ -33,6 +33,27 @@ class StringsTest {
expect(compareStrings('b', 'a'), 1);
}
+ void test_computeSimpleDiff() {
+ assertDiff(String oldStr, String newStr) {
+ SimpleDiff diff = computeSimpleDiff(oldStr, newStr);
+ expect(diff.offset, isNonNegative);
+ expect(diff.length, isNonNegative);
+ String applied = oldStr.substring(0, diff.offset) +
+ diff.replacement +
+ oldStr.substring(diff.offset + diff.length);
+ expect(applied, newStr);
+ }
+ assertDiff('', '');
+ assertDiff('', 'a');
+ assertDiff('abc', '');
+ assertDiff('abcd', 'acd');
+ assertDiff('a', 'b');
+ assertDiff('12345xyz', '12345abcxyz');
+ assertDiff('12345xyz', '12345xyzabc');
+ assertDiff('abbc', 'abbbc');
+ assertDiff('abbbbc', 'abbbbbbc');
+ }
+
void test_countMatches() {
expect(countMatches(null, null), 0);
expect(countMatches('abc', null), 0);
@@ -42,15 +63,6 @@ class StringsTest {
expect(countMatches('aaabaa', 'aa'), 2);
}
- void test_findCommonOverlap() {
- expect(findCommonOverlap('', 'abcd'), 0);
- expect(findCommonOverlap('abc', 'abcd'), 3);
- expect(findCommonOverlap('123456', 'abcd'), 0);
- expect(findCommonOverlap('123456xxx', 'xxxabcd'), 3);
- expect(findCommonOverlap('123456', '56'), 2);
- expect(findCommonOverlap('56', '56789'), 2);
- }
-
void test_findCommonPrefix() {
expect(findCommonPrefix('abc', 'xyz'), 0);
expect(findCommonPrefix('1234abcdef', '1234xyz'), 4);
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/strings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698