implement diff of a sequence (for speed and c++ play).
This commit is contained in:
@@ -2,41 +2,32 @@ import pywikidiff2
|
||||
import json
|
||||
num_context_lines = 100000
|
||||
obj = pywikidiff2.pywikidiff2()
|
||||
|
||||
obj = pywikidiff2.pywikidiff2(numContextLines=num_context_lines,
|
||||
moved_paragraph_detection_cutoff=20000)
|
||||
assert obj.num_context_lines() == num_context_lines
|
||||
print(obj.moved_line_threshold())
|
||||
print(obj.change_threshold())
|
||||
print(obj.moved_paragraph_detection_cutoff())
|
||||
print(obj.max_split_size())
|
||||
print(obj.initial_split_threshold())
|
||||
print(obj.final_split_threshold())
|
||||
moved_paragraph_detection_cutoff=2000000)
|
||||
# res = obj.inline_json_diff("help! \n I'm alive", "help! \n dead I am")
|
||||
# print(res)
|
||||
|
||||
res = obj.inline_json_diff("help! \n I'm alive", "help! \n dead I am")
|
||||
res = obj.inline_json_diff_sequence([open("test/1295229484",'r').read(),
|
||||
open("test/1295229484_parmove_and_change",'r').read()],
|
||||
numContextLines=num_context_lines)
|
||||
print(res)
|
||||
print(obj.num_context_lines())
|
||||
res = obj.inline_json_diff(open("test/err_last_text",'r').read(),
|
||||
open("test/err_text",'r').read(),
|
||||
numContextLines=10000)
|
||||
|
||||
assert obj.num_context_lines() == 10000
|
||||
print("Successfully completed diff sequence!")
|
||||
assert json.loads(res[0])['diff'][0]['type'] == 1
|
||||
print("Sequence diff passes assert 0")
|
||||
print(res[1])
|
||||
assert json.loads(res[1])['diff'][0]['type'] == 0
|
||||
print("Sequence diff passes assert 1")
|
||||
assert obj.num_context_lines() == num_context_lines
|
||||
print("Sequence diff passes assert 3")
|
||||
|
||||
res = obj.inline_json_diff("",
|
||||
open("test/1295229484",'r').read(),
|
||||
numContextLines=1000)
|
||||
assert obj.num_context_lines() == 1000
|
||||
|
||||
res = obj.inline_json_diff(open("test/1285792388",'r').read(),
|
||||
open("test/1295229484",'r').read(),
|
||||
numContextLines=1000)
|
||||
|
||||
res = obj.inline_json_diff("",
|
||||
open("test/1295229484_parmove_and_change",'r').read(),
|
||||
numContextLines=1000)
|
||||
print('\n')
|
||||
print(res)
|
||||
res = obj.inline_json_diff(open("test/1295229484",'r').read(),
|
||||
open("test/1295229484_parmove_and_change",'r').read())
|
||||
res = json.loads(res)
|
||||
assert res["diff"][0]["type"] == 0
|
||||
|
||||
print("Success!")
|
||||
|
||||
Reference in New Issue
Block a user