-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff_test.dart
More file actions
48 lines (43 loc) · 960 Bytes
/
diff_test.dart
File metadata and controls
48 lines (43 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//Copyright (C) 2022 Potix Corporation. All Rights Reserved.
//History: Thu Jun 30 16:51:37 CST 2022
// Author: tomyeh
library common.diff_test;
import "dart:convert";
import "package:rikulo_commons/util.dart" show convertListNS;
import "package:test/test.dart";
import "package:diff_match_patch2/diff_match_patch.dart";
void main() {
test("simple", () {
final oldText = '''
000
aaa
bbb
ccc
ddd
eee
fff
ggg
hhh
iii''',
newText = '''
000
aaa
ccc
bbb
jjj
eee
fff
ggg
hhh
iii''';
final dmp = DiffMatchPatch(),
//diff = dmp.diff_main(oldText, newText),
patch = dmp.patch_main(oldText, newText);;
print("${patch.length}: ${patch.map((p) => p.toGnuString())}");
expect(dmp.patch_apply(patch, oldText).first, newText);
//test json encode and decode
final enc = json.encode(patch);
final p2 = convertListNS(json.decode(enc) as List, Patch.fromJson);
expect(dmp.patch_apply(p2, oldText).first, newText);
});
}