
    .d!                        d Z ddlZddlZddlZddlZddlZej                  j                  d      Zeej                  vrej                  j                  de       ddl
Z ej                  e        G d dej                        Z G d de      Z G d d	e      Z G d
 de      Zedk(  r ej&                          yy)a  Diff Match and Patch -- Test harness
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.
    Nz..c                       e Zd Zd Zd Zy)DiffMatchPatchTestc                 6    t        j                         | _        y)zTest harness for dmp_module.N)
dmp_modulediff_match_patchdmpselfs    N/usr/lib/python3/dist-packages/diff_match_patch/tests/diff_match_patch_test.pysetUpzDiffMatchPatchTest.setUp%   s    ..0    c                     d}d}t        dt        |            D ]_  }||   d   t        j                  j                  k7  r|||   d   z  }||   d   t        j                  j
                  k7  sU|||   d   z  }a ||fS )N r      )rangelenr   r   DIFF_INSERTDIFF_DELETE)r
   diffstext1text2xs        r   diff_rebuildtextsz$DiffMatchPatchTest.diff_rebuildtexts)   s    q#e*% 	%AQx{j99EEEq!$Qx{j99EEEq!$		%
 u~r   N)__name__
__module____qualname__r   r    r   r   r   r   $   s    1	r   r   c                   v    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)DiffTestzDIFF TEST FUNCTIONSc                    | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             y )Nr   abcxyz   
1234abcdef1234xyz1234)assertEqualr   diff_commonPrefixr	   s    r   testDiffCommonPrefixzDiffTest.testDiffCommonPrefix8   k     	DHH66ueDE 	DHH66|YOP 	DHH66vyIJr   c                    | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             y )Nr   r!   r"   r#   
abcdef1234xyz1234r&   )r'   r   diff_commonSuffixr	   s    r   testDiffCommonSuffixzDiffTest.testDiffCommonSuffixC   r*   r   c                    | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             | j                  d| j                  j                  dd             | j                  d| j                  j                  d	d
             y )Nr   r   abcd   r!   123456	123456xxxxxxabcdfiu   ﬁi)r'   r   diff_commonOverlapr	   s    r   testDiffCommonOverlapzDiffTest.testDiffCommonOverlapN   s    DHH77FCD 	DHH77vFG 	DHH77&IJ 	DHH77YOP
 	DHH77iHIr   c                    d| j                   _        | j                  d | j                   j                  dd             | j                  d | j                   j                  dd             | j                  d| j                   j                  dd             | j                  d| j                   j                  dd             | j                  d	| j                   j                  d
d             | j                  d| j                   j                  dd             | j                  d| j                   j                  dd             | j                  d| j                   j                  dd             | j                  d| j                   j                  dd             | j                  d| j                   j                  dd             d| j                   _        | j                  d | j                   j                  dd             y )Nr   
1234567890abcdef1234523)1290az345678a345678z)r@   rA   r>   r?   rB   )r!   rA   r&   056789	abc56789z)r@   r"   1789023456	a23456xyz)12123123121r@   rA   1234123451234121231234123451234123121a1234123451234z)r   
-=-=-=-=-=r   r   zx-=-=-=-=-=-=-=zx-=-=-=-=-=-=-=-=-=-=-=-=zxx-=-=-=-=-=-=-=)rP   r   r   yz-=-=-=-=-=-=-=yz-=-=-=-=-=-=-=-=-=-=-=-=yz-=-=-=-=-=-=-=yy)qHillowr   HulloyHelloHeqHilloHelloHewxHelloHeHulloyr   )r   Diff_Timeoutr'   diff_halfMatchr	   s    r   testDiffHalfMatchzDiffTest.testDiffHalfMatch`   s    !txx66|XNOtxx66wEF 	,HH##L*=	

 	,HH##J=	

 	.HH##K>	

 	.HH##K>	
 	:HH##$>@QR	

 	:HH##$?AST	

 	:HH##$?AST	
 	5HH##$46FG	
 !"$(())*:<LM	
r   c                    | j                  ddg df| j                  j                  dd             | j                  ddg df| j                  j                  dd	             | j                  d
dg df| j                  j                  dd             d}g }g }t        d|dz         D ]9  }|j	                  t        |      dz          |j	                  t        |             ; | j                  |t        |             dj                  |      }dj                  |      }| j                  |t        |             |j                  dd       | j                  |d|f| j                  j                  |d             y )Nr   zalpha
zbeta
alpha
beta
alpha
beta
alpha
beta
r   z)r   zalpha
zbeta
z
zalpha
beta


)r   r@   br@   rc   ,  r   
r   )
r'   r   diff_linesToCharsr   appendstrchrr   joininsert)r
   nlineListcharListilinescharss          r   testDiffLinesToCharszDiffTest.testDiffLinesToChars   sZ   ^-FGHH&&'=?TU	

 	#%JKHH&&r+FG	

 	V^,dhh.H.Hc.R	

 q!a% 	$AOOCFTM*OOCF#	$ 	CM*!!CJ'2%X.0J0J5RT0UVr   c                    | j                   j                  df| j                   j                  dfg}| j                   j                  |g d       | j	                  | j                   j                  df| j                   j                  dfg|       d}g }g }t        d|dz         D ]9  }|j                  t        |      dz          |j                  t        |             ; | j	                  |t        |             d	j                  |      }d	j                  |      }| j	                  |t        |             |j                  d
d	       | j                   j                  |fg}| j                   j                  ||       | j	                  | j                   j                  |fg|       g }t        dd      D ]  }|j                  t        |      dz          ! d	j                  |      }| j                   j                  |d	      }| j                   j                  |d
   fg}| j                   j                  ||d          | j	                  ||d
   d          y )Nr\   r]   r^   r_   r`   rd   r   re   r   r   iy    )r   
DIFF_EQUALr   diff_charsToLinesr'   r   rg   rh   ri   r   rj   rk   r   rf   )	r
   r   rl   rm   rn   ro   rp   rq   resultss	            r   testDiffCharsToLineszDiffTest.testDiffCharsToLines   s    XX  .1XX!!>2
 	""5*CD$$&<=%%'<= 	
 q!a% 	$AOOCFTM*OOCF#	$ 	CM*!!CJ'2((&&./""5(3488//78%@ q+& 	+AOOCFTM*	+!((,,UB7((&&
34""5'!*5a,r   c                    g }| j                   j                  |       | j                  g |       | j                   j                  df| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j
                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  dfg|       | j                   j
                  df| j                   j
                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j
                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  d	f| j                   j                  d
fg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j
                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j
                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j
                  df| j                   j                  dfg|       y )Nr@   rc   cr!   defacbdefdcr   rQ   xacybaabcaacxxcacbabcr   )r   diff_cleanupMerger'   ru   r   r   r
   r   s     r   testDiffCleanupMergezDiffTest.testDiffCleanupMerge   s
    ""5)U# XX  #&XX!!3'XX!!3'

 	""5)$$c*%%s+%%s+
 	
 XX  #&XX  #&XX  #&

 	""5)488..67? XX!!3'XX!!3'XX!!3'

 	""5)488//78%@ XX!!3'XX!!3'XX!!3'

 	""5)488//78%@ XX!!3'XX!!3'XX!!3'XX!!3'XX  #&XX  #&
 	""5)%%t,%%t,$$d+
 	
 XX!!3'XX!!5)XX!!4(

 	""5)$$c*%%s+%%s+$$c*	 	
 XX  #&XX!!3'XX!!5)XX!!4(XX  #&
 	""5)$$d+%%s+%%s+$$d+	 	
 XX  #&XX!!4(XX  #&

 	""5)hh""D)DHH,?,?+FG	
 XX  #&XX!!4(XX  #&

 	""5)hh!!4(488+?+?*FG	
 XX  #&XX!!3'XX  #&XX!!4(XX  #&
 	""5)hh""E*TXX-@-@%,HI5	
 XX  #&XX!!4(XX  #&XX!!3'XX  #&
 	""5)hh!!5)DHH,@,@%+HI5	
 XX!!3'XX!!4(XX  #&

 	""5)hh""C(488+>+>*EF	
 XX  "%XX!!3'XX  #&

 	""5)hh""C(488+>+>*DEu	
r   c                 $
   g }| j                   j                  |       | j                  g |       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  d	fg}| j                   j                  |       | j                  | j                   j                  d
f| j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j
                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  dfg|       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  d f| j                   j                  d!fg|       y )"Nz
AAA

BBBz
DDD

BBBz
EEEzAAA

zBBB
DDD

zBBB
EEEzAAA
BBBz	 DDD
BBBz EEEzAAA
z	BBB DDD
zBBB EEEThe cow and the cat.The cow and the cat.zThe-czow-and-the-czThe-zcow-and-the-r@   axaaxr   xaazThe xxx. The z	zzz. The zyyy.zThe xxx.z	 The zzz.z	 The yyy.)r   diff_cleanupSemanticLosslessr'   ru   r   r   r   s     r   testDiffCleanupSemanticLosslessz(DiffTest.testDiffCleanupSemanticLossless  se    --e4U# XX  "23XX!!#78XX  ),

 	--e4$$m4%%';<$$l3
 	
 XX  ,/XX!!=1XX  &)

 	--e4$$i0%%}5$$i0
 	
 XX  '*XX!!>2XX  %(

 	--e4$$f-%%~6$$f-
 	
 XX  '*XX!!>2XX  %(

 	--e4$$f-%%~6$$f-
 	
 XX  #&XX!!3'XX  $'

 	--e4hh""C(488+>+>*FG	
 XX  $'XX!!3'XX  #&

 	--e4hh!!5)DHH,@,@#+FG	
 XX  /2XX!!;/XX  &)

 	--e4$$j1%%{3$$k2
 	
r   c           
         g }| j                   j                  |       | j                  g |       | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg|       | j                   j                  d	f| j                   j
                  d
f| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  d
fg|       | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j
                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  df| j                   j
                  df| j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  dfg	}| j                   j                  |       | j                  | j                   j                  df| j                   j                  dfg|       | j                   j
                  df| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j
                  df| j                   j                  df| j                   j
                  dfg|       | j                   j                  df| j                   j                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j                  dfg|       | j                   j                  df| j                   j                  d fg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  d!f| j                   j                  d"fg|       | j                   j                  d#f| j                   j                  d$fg}| j                   j                  |       | j                  | j                   j                  d"f| j                   j
                  d!f| j                   j                  dfg|       | j                   j                  d%f| j                   j                  d&f| j                   j
                  d'f| j                   j                  d(f| j                   j                  d)fg}| j                   j                  |       | j                  | j                   j                  d*f| j                   j
                  d+f| j                   j                  d,f| j                   j
                  d'f| j                   j                  df| j                   j
                  d-f| j                   j                  d.fg|       y )/Nr   cdr>   r|   r!   ABCr&   wxyzr@   rc   rz   r}   gr;   cdfgrG   AB2_AB_AB1A2_1A2r   r   r   r   r   r   abcxxxxdefabcxxxxxxdefxxxdefxxxabcdefxxxabcd1212	1212efghiz----A33BCr1   1212efghi3BC)r   diff_cleanupSemanticr'   r   r   ru   r   s     r   testDiffCleanupSemanticz DiffTest.testDiffCleanupSemantic  s    %%e,U# XX!!4(XX!!4(XX  $'XX!!3'	
 	%%e,%%t,%%t,$$d+%%s+	 	
 XX!!5)XX!!5)XX  &)XX!!6*	
 	%%e,%%u-%%u-$$f-%%v.	 	
 XX!!3'XX  #&XX!!3'

 	%%e,hh""E*TXX-A-A3,GH%	
 XX!!4(XX  $'XX!!3'XX  #&XX!!3'
 	%%e,hh""H-0D0Df/MNPU	
 XX!!3'XX  #&XX!!3'XX!!3'XX  #&XX!!3'XX  #&XX!!3'XX!!3'

 	%%e,hh""G,txx/C/CY.OPRW	
 XX  '*XX!!>2XX  %(

 	%%e,$$f-%%~6$$f-
 	
 ((&&04883G3G2QR%%e,hh""G,txx/C/CW.MNPU	

 ((&&1DHH4H4H(3ST%%e,%%u-$$e,%%u-
 	
 ((&&1DHH4H4H(3ST%%e,%%u-$$e,%%u-
 	
 XX!!:.XX!!;/XX  &)XX!!4(XX!!5)
 	%%e,%%v.$$f-%%w/$$f-%%s+$$c*%%t, 	
r   c                 	   d| j                   _        g }| j                   j                  |       | j                  g |       | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  df| j                   j
                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  d	fg|       | j                   j
                  df| j                   j                  d
f| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  dfg|       | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  dfg|       d| j                   _        | j                   j                  df| j                   j
                  df| j                   j                  df| j                   j                  df| j                   j
                  dfg}| j                   j                  |       | j                  | j                   j                  df| j                   j
                  dfg|       d| j                   _        y )Nr#   r   r>   r   r   34r"   abxyzcd12xyz34r   xcd12x34xyrA   56	12xy34z56   abwxyzcd12wxyz34)r   Diff_EditCostdiff_cleanupEfficiencyr'   r   r   ru   r   s     r   testDiffCleanupEfficiencyz"DiffTest.testDiffCleanupEfficiency  s   !"''.U# XX!!4(XX!!4(XX  &)XX!!4(XX!!4(
 	''.%%t,%%t,$$f-%%t,%%t, 		
 XX!!4(XX!!4(XX  %(XX!!4(XX!!4(
 	''.hh""I.1E1Ey0QR	
 XX!!4(XX  #&XX!!4(XX!!4(	
 	''.hh""E*TXX-A-A7,KLe	
 XX!!4(XX!!4(XX  $'XX!!4(XX  #&XX!!4(XX!!4(
 	''.hh""I.1E1E{0ST	
 "#XX!!4(XX!!4(XX  &)XX!!4(XX!!4(
 	''.hh""J/$((2F2F
1ST	
 "#r   c                     | j                   j                  df| j                   j                  df| j                   j                  dfg}| j	                  d| j                   j                  |             y )Nza
z<B>b</B>zc&dz<span>a&para;<br></span><del style="background:#ffe6e6;">&lt;B&gt;b&lt;/B&gt;</del><ins style="background:#e6ffe6;">c&amp;d</ins>)r   ru   r   r   r'   diff_prettyHtmlr   s     r   testDiffPrettyHtmlzDiffTest.testDiffPrettyHtml  si     XX  %(XX!!:.XX!!5)

 	 PHH$$U+	
r   c                    | j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  dfg}| j	                  d| j                   j                  |             | j	                  d	| j                   j                  |             y )
Njumpsed over ther@    lazyjumps over the lazyzjumped over a lazy)r   ru   r   r   r'   
diff_text1
diff_text2r   s     r   testDiffTextzDiffTest.testDiffText  s     XX  &)XX!!3'XX!!4(XX  (+XX!!5)XX!!3'XX  '*
 	.0C0CE0JK-txx/B/B5/IJr   c           	      x   | j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j	                  |      }| j                  d	|       | j                   j                  |      }| j                  d
|       | j                  || j                   j                  ||             	 | j                   j                  |dz   |       | j                  d       	 | j                   j                  |dd  |       | j                  d       | j                   j                  df| j                   j                  df| j                   j                  dfg}| j                   j	                  |      }| j                  d|       | j                   j                  |      }| j                  d|       | j                  || j                   j                  ||             | j                   j                  dfg}| j                   j                  |      }| j                  d|       | j                   j                  |      }| j                  d|       | j                  || j                   j                  d|             d}t        d      D ]  }||z  }	 | j                   j                  |fg}| j                   j                  |      }| j                  d|z   |       | j                  || j                   j                  d|             y # t        $ r Y 6w xY w# t        $ r Y w xY w)Nr   r   r   r   r   r@   r   zold dogr   z=4	-1	+ed	=6	-3	+a	=5	+old dogr   Tr   u   ڀ   	 %u   ځ  
 ^u   ڂ  \ |u   ڀ   	 %ځ  
 ^z=7	-7	+%DA%82 %02 %5C %7Cz4A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # z5+A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # r   
abcdefghij   +)r   ru   r   r   r   r'   diff_toDeltadiff_fromDeltaassertFalse
ValueErrorr   r   )r
   r   r   deltar   r@   ro   s          r   testDiffDeltazDiffTest.testDiffDelta  sO    XX  &)XX!!3'XX!!4(XX  (+XX!!5)XX!!3'XX  '*XX!!9-	
 ##E*.6%%e,@%H 	 7 7u EF	HH##ECK7T"	HH##E!"Iu5T"  XX  "45XX!!#56XX!!#56

 ##E*;UC%%e,6> 	 7 7u EF
 $$F
 ##E*OQVW%%e,PRWX 	 7 7E BC r 	AFA	((&&*+%%e,q%( 	 7 7E BC{  		  		s$   0N 30N, 	N)(N),	N98N9c           	         | j                  d| j                  j                  | j                  j                  df| j                  j                  df| j                  j
                  dfgd             | j                  d| j                  j                  | j                  j
                  df| j                  j                  df| j                  j
                  dfgd             y )Nr   r@   r&   r"   rt   r   r2   )r'   r   diff_xIndexr   r   ru   r	   s    r   testDiffXIndexzDiffTest.testDiffXIndex_  s    HH  XX))3/XX))62XX((%0
 
	
 	HH  XX((#.XX))62XX((%0
 
	
r   c           	         | j                  d| j                  j                  | j                  j                  df| j                  j                  df| j                  j
                  dfg             | j                  d| j                  j                  | j                  j
                  df| j                  j                  df| j                  j                  dfg             | j                  d| j                  j                  | j                  j                  df| j                  j
                  df| j                  j                  dfg             y )Nr#   r!   r&   r"      )r'   r   diff_levenshteinr   r   ru   r	   s    r   testDiffLevenshteinzDiffTest.testDiffLevenshteinz  s    HH%%XX))51XX))62XX((%0		
 	HH%%XX((%0XX))51XX))62		
 	HH%%XX))51XX((%0XX))62		
r   c                    d}d}| j                  | j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  dfg| j                  j                  ||t        j                               | j                  | j                  j                  df| j                  j                  dfg| j                  j                  ||d             y )	Ncatmaprz   mr@   tpr   )r'   r   r   r   ru   diff_bisectsysmaxsize)r
   r@   rc   s      r   testDiffBisectzDiffTest.testDiffBisect  s     	%%s+%%s+$$c*%%s+%%s+ HH  As{{3		
 	hh""E*TXX-A-A5,IJHH  Aq)	
r   c                 P   | j                  g | j                  j                  ddd             | j                  | j                  j                  dfg| j                  j                  ddd             | j                  | j                  j                  df| j                  j                  df| j                  j                  dfg| j                  j                  ddd             | j                  | j                  j                  df| j                  j
                  df| j                  j                  d	fg| j                  j                  d
dd             | j                  | j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  dfg| j                  j                  ddd             | j                  | j                  j                  df| j                  j
                  df| j                  j                  df| j                  j
                  df| j                  j                  dfg| j                  j                  ddd             d| j                  _        | j                  | j                  j
                  df| j                  j                  dfg| j                  j                  ddd             | j                  | j                  j
                  df| j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  dfg| j                  j                  ddd             | j                  | j                  j
                  df| j                  j                  df| j                  j                  df| j                  j
                  df| j                  j                  dfg| j                  j                  ddd             | j                  | j                  j
                  df| j                  j                  df| j                  j
                  df| j                  j                  df| j                  j
                  df| j                  j                  dfg| j                  j                  d d!d             | j                  | j                  j                  d"f| j                  j                  df| j                  j
                  dfg| j                  j                  d#d$d             | j                  | j                  j
                  d%f| j                  j                  df| j                  j
                  d&f| j                  j                  d'f| j                  j                  d(f| j                  j
                  d&f| j                  j                  d'f| j                  j                  d)f| j                  j
                  d*fg	| j                  j                  d+d,d             | j                  | j                  j                  d-f| j                  j                  df| j                  j                  d.f| j                  j                  d/f| j                  j
                  d0fg| j                  j                  d1d2d             d3| j                  _        d4}d5}t        d6      D ]  }||z  }||z  } t        j                         }| j                  j                  ||       t        j                         }| j                  | j                  j                  ||z
  k         | j                  | j                  j                  d7z  ||z
  kD         d| j                  _        d8}d9}| j                  | j                  j                  ||d      | j                  j                  ||d:             d;}d<}| j                  | j                  j                  ||d      | j                  j                  ||d:             d8}d=}| j                  | j                  j                  ||d:            }| j                  | j                  j                  ||d            }| j                  ||       	 | j                  j                  d d        | j                  d:       y # t        $ r Y y w xY w)>Nr   Fr!   r   123rz   ab123cr@   r   a123bcrc   456	a123b456cr   AppleBananazs are alsoz fruit.zApples are a fruit.zBananas are also fruit.u   ڀr   	 zax	u   ڀx rG   rQ   r   xab1ayb2abxabxaxcxabcyxaxcxabcABCD=-bcdefghijklmnopqrsEFGHIJKLMNOefgz'ABCDa=bcd=efghijklmnopqrsEFGHIJKLMNOefgza-bcd-efghijklmnopqrs ndz [[Pennsylvania]]z
 and [[Newza [[Pennsylvania]] and [[Newz and [[Pennsylvania]]g?z`Twas brillig, and the slithy toves
Did gyre and gimble in the wabe:
All mimsy were the borogoves,
And the mome raths outgrabe.
zI am the very model of a modern major general,
I've information vegetable, animal, and mineral,
I know the kings of England, and I quote the fights historical,
From Marathon to Waterloo, in order categorical.

   rt   z1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
zabcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
abcdefghij
Tڂ1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890ڂabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijzabcdefghij
1234567890
1234567890
1234567890
abcdefghij
1234567890
1234567890
1234567890
abcdefghij
1234567890
1234567890
1234567890
abcdefghij
)r'   r   	diff_mainru   r   r   rX   r   time
assertTruer   r   r   )r
   r@   rc   ro   	startTimeendTimetexts_linemodetexts_textmodes           r   testDiffMainzDiffTest.testDiffMain  s    	TXX//B>? 	hh!!5)*DHH,>,>ueU,S	

 	$$d+%%u-$$c*
 HHuh6	
 	$$c*%%u-$$d+
 HHx6	
 	$$c*%%u-$$c*%%u-$$c* HHuk59		
 	$$c*%%u-$$c*%%u-$$c* HH{E59		
 !"hh""C(488+?+?*EFHHsC/	

 	%%w/%%x0$$i0%%u-$$i0 HH46OQVW		
 	%%s+%%x0$$c*%%t,%%v. HHv}e<		
 	%%s+$$c*%%s+$$c*%%s+%%u- HHw7
	
 	%%w/$$e,%%s+
 HHvz59	
 	%%v.$$c*%%s+%%s+$$e,%%s+%%s+$$&78%%'78
 HH9'	
( 	%%s+$$c*%%t,$$&9:%%|4 HH.0G	
 !$ S dr 	AFAFA	 IIK	1a ))+--91DDE 	--1Gi4GGH !
  HHq!U+TXX-?-?1d-K	

 HHq!U+TXX-?-?1d-K	

   k//0B0B1a0NO//0B0B1a0OP8	HHtT*T" 		s   +-d 	d%$d%N)r   r   r   __doc__r)   r/   r8   rZ   rr   rx   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   5   sn    	K	KJ$8
tW<'-Rm
^k
ZW
rT#l

KVDp
6!
F
0|r   r   c                   "    e Zd ZdZd Zd Zd Zy)	MatchTestzMATCH TEST FUNCTIONSc                     | j                  dddd| j                  j                  d             | j                  dddd| j                  j                  d	             y )
Nr#   rt   r   )r@   rc   rz   r!   %         abcaba)r'   r   match_alphabetr	   s    r   testMatchAlphabetzMatchTest.testMatchAlphabetw  sN    qqq14883J3J53QRr3TXX5L5LX5VWr   c                    d| j                   _        d| j                   _        | j                  d| j                   j	                  ddd             | j                  d| j                   j	                  ddd             | j                  d| j                   j	                  ddd             | j                  d	| j                   j	                  dd
d             | j                  d| j                   j	                  ddd             | j                  d	| j                   j	                  ddd	             | j                  d| j                   j	                  ddd             | j                  d| j                   j	                  ddd             | j                  d| j                   j	                  ddd             d| j                   _        | j                  d| j                   j	                  ddd             d| j                   _        | j                  d| j                   j	                  ddd             d| j                   _        | j                  d| j                   j	                  ddd             d| j                   _        | j                  d| j                   j	                  ddd             | j                  d| j                   j	                  ddd             d| j                   _        | j                  d| j                   j	                  ddd              | j                  d| j                   j	                  dd!d             d"| j                   _        | j                  d| j                   j	                  ddd              y )#Nd         ?r   abcdefghijkfghr   r#   efxhirt   
cdefxyhijkbxyr   123456789xx0	3456789x0r;   xxabcr2   defyyxabcdefyg?efxyhig333333?        bcdefabcdexyzabcdeabccder  r	  abcdefghijklmnopqrstuvwxyzabcdefg   	abcdxxefg  )r   Match_DistanceMatch_Thresholdr'   match_bitapr	   s    r   testMatchBitapzMatchTest.testMatchBitap}  s   "%#& DHH00qIJDHH00qIJ 	DHH00KLDHH00aPQTXX11-JK 	DHH00aPQDHH007AFGDHH007AFGDHH00:qIJ $' DHH00!LM#& TXX11-1MN#& DHH00KL#&  	DHH00(ANODHH00(ANO #%$$%A9bQ	
 	txx##$@+qQ	
 #'txx##$@)RP	
r   c                 :   | j                  d| j                  j                  ddd             | j                  d| j                  j                  ddd             | j                  d| j                  j                  ddd             | j                  d| j                  j                  ddd             | j                  d| j                  j                  dd	d
             | j                  d| j                  j                  ddd             d| j                  _        | j                  d
| j                  j                  ddd             d| j                  _        	 | j                  j                  d d d       | j	                  d       y # t
        $ r Y y w xY w)Nr   r;   r5  r%  r   r   r2   dedefyr#   abcdefygffffff?.I am the very model of a modern major general.z that berry r   r   T)r'   r   
match_mainr7  r   r   r	   s    r   testMatchMainzMatchTest.testMatchMain  sX    	DHH//(DIJTXX00XqABDHH//"a@ADHH//$BCDHH//&!DEDHH//)QGH $' HH@.RS	
 $' 	HHdA.T" 		s   .F 	FFN)r   r   r   r  r  r9  r@  r   r   r   r  r  t  s    X5
nr   r  c                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)	PatchTestzPATCH TEST FUNCTIONSc                    t        j                         }d|_        d|_        d|_        d|_        | j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  df| j                  j                  d	f| j                  j                  d
f| j                  j                  dfg|_
        t        |      }| j                  d|       y )N      r     r   r   r   r   r   r@   z
laz9@@ -21,18 +22,17 @@
 jump
-s
+ed
  over 
-the
+a
 %0Alaz
)r   	patch_objstart1start2length1length2r   ru   r   r   r   rh   r'   )r
   r   strps      r   testPatchObjzPatchTest.testPatchObj  s      "		XX  &)XX!!3'XX!!4(XX  (+XX!!5)XX!!3'XX  '*
 1vOQU	
r   c                    | j                  g | j                  j                  d             d}| j                  |t        | j                  j                  |      d                | j                  dt        | j                  j                  d      d                | j                  dt        | j                  j                  d      d                | j                  dt        | j                  j                  d      d                	 | j                  j                  d       | j	                  d       y # t
        $ r Y y w xY w)	Nr   rG  r   z@@ -1 +1 @@
-a
+b
z@@ -1,3 +0,0 @@
-abc
z@@ -0,0 +1,3 @@
+abc
z
Bad
Patch
T)r'   r   patch_fromTextrh   r   r   )r
   rM  s     r   testPatchFromTextzPatchTest.testPatchFromText  s   TXX44R89Rs488#:#:4#@#CDE#''(?@CD	

 	%''(AB1EF	

 	%''(AB1EF	
	HH##N3T" 		s   ,D8 8	EEc                 $   d}| j                   j                  |      }| j                  || j                   j                  |             d}| j                   j                  |      }| j                  || j                   j                  |             y )Nz7@@ -21,18 +22,17 @@
 jump
-s
+ed
  over 
-the
+a
  laz
zA@@ -1,9 +1,9 @@
-f
+F
 oo+fooba
@@ -7,9 +7,9 @@
 obar
-,
+.
 tes
)r   rP  r'   patch_toText)r
   rM  r   s      r   testPatchToTextzPatchTest.testPatchToText  sz    PHH##D)txx44Q78 Y 	 HH##D)txx44Q78r   c                    d| j                   _        | j                   j                  d      d   }| j                   j                  |d       | j	                  dt        |             | j                   j                  d      d   }| j                   j                  |d       | j	                  dt        |             | j                   j                  d      d   }| j                   j                  |d       | j	                  d	t        |             | j                   j                  d      d   }| j                   j                  |d
       | j	                  dt        |             y )Nr#   z%@@ -21,4 +21,10 @@
-jump
+somersault
r   ,The quick brown fox jumps over the lazy dog.z2@@ -17,12 +17,18 @@
 fox 
-jump
+somersault
 s ov
zThe quick brown fox jumps.z0@@ -17,10 +17,16 @@
 fox 
-jump
+somersault
 s.
z@@ -3 +3,2 @@
-e
+at
z!@@ -1,7 +1,8 @@
 Th
-e
+at
  qui
z8The quick brown fox jumps.  The quick brown fox crashes.z7@@ -1,27 +1,28 @@
 Th
-e
+at
  quick brown fox jumps. 
)r   Patch_MarginrP  patch_addContextr'   rh   )r
   r   s     r   testPatchAddContextzPatchTest.testPatchAddContext  s2    !HH##$NOPQR!!!%STEs1v	

 HH##$NOPQR!!!%ABCSV	

 HH##$>?B!!!%ABA3q6J HH##$>?B!!I	
 	JCPQF	
r   c                 D   | j                   j                  dd      }| j                  d| j                   j                  |             d}d}d}| j                   j                  ||      }| j                  || j                   j                  |             d}| j                   j                  ||      }| j                  || j                   j                  |             | j                   j	                  ||d      }| j                   j                  |      }| j                  || j                   j                  |             | j                   j                  ||      }| j                  || j                   j                  |             | j                   j                  |||      }| j                  || j                   j                  |             | j                   j                  dd      }| j                  d	| j                   j                  |             | j                   j
                  df| j                   j                  dfg}| j                  || j                   j                  d	      d
   j                         d}t        d      D ]  }|dz  }	 |dz   }d}| j                   j                  ||      }| j                  || j                   j                  |             	 | j                   j                  d d        | j                  d       y # t        $ r Y y w xY w)Nr   rV  ,That quick brown fox jumped over a lazy dog.zX@@ -1,8 +1,7 @@
 Th
-at
+e
  qui
@@ -21,17 +21,18 @@
 jump
-ed
+s
  over 
-a
+the
  laz
z^@@ -1,11 +1,12 @@
 Th
-e
+at
  quick b
@@ -22,18 +22,17 @@
 jump
-s
+ed
  over 
-the
+a
  laz
Fz`1234567890-=[]\;',./z~!@#$%^&*()_+{}|:"<>?zX@@ -1,21 +1,21 @@
-%601234567890-=%5B%5D%5C;',./
+~!@#$%25%5E&*()_+%7B%7D%7C:%22%3C%3E?
r   r  r;   r   z9@@ -573,28 +573,31 @@
 cdefabcdefabcdefabcdefabcdef
+123
T)r   
patch_maker'   rS  r  r   r   rP  r   r   r   r   )r
   patchesr   r   expectedPatchr   r   s          r   testPatchMakezPatchTest.testPatchMake3  s   ((%%b"-TXX227;<>>((%%eU3(=(=g(FG F((%%eU3(=(=g(FG ""5%7((%%e,(=(=g(FG ((%%eU3(=(=g(FG ((%%eUE:(=(=g(FG ((%%&>@WXiHH!!'*	
 XX!!#;<XX!!#:;
 	HH##m		
 s 	AXE	V((%%eU3(=(=g(FG	HHd+T" 		s   %-L 	LLc                 J   | j                   j                  dd      }| j                   j                  |       | j                  d| j                   j	                  |             | j                   j                  dd      }| j                   j	                  |      }| j                   j                  |       | j                  || j                   j	                  |             | j                   j                  dd      }| j                   j                  |       | j                  d| j                   j	                  |             | j                   j                  d	d
      }| j                   j                  |       | j                  d| j                   j	                  |             y )N%abcdefghijklmnopqrstuvwxyz012345678908XabXcdXefXghXijXklXmnXopXqrXstXuvXwxXyzX01X23X45X67X89X0z@@ -1,32 +1,46 @@
+X
 ab
+X
 cd
+X
 ef
+X
 gh
+X
 ij
+X
 kl
+X
 mn
+X
 op
+X
 qr
+X
 st
+X
 uv
+X
 wx
+X
 yz
+X
 012345
@@ -25,13 +39,18 @@
 zX01
+X
 23
+X
 45
+X
 67
+X
 89
+X
 0
Rabcdef1234567890123456789012345678901234567890123456789012345678901234567890uvwxyzabcdefuvwxyzF1234567890123456789012345678901234567890123456789012345678901234567890r!   z@@ -1,32 +1,4 @@
-1234567890123456789012345678
 9012
@@ -29,32 +1,4 @@
-9012345678901234567890123456
 7890
@@ -57,14 +1,3 @@
-78901234567890
+abc
zPabcdefghij , h : 0 , t : 1 abcdefghij , h : 0 , t : 1 abcdefghij , h : 0 , t : 1zPabcdefghij , h : 1 , t : 1 abcdefghij , h : 1 , t : 1 abcdefghij , h : 0 , t : 1zx@@ -2,32 +2,32 @@
 bcdefghij , h : 
-0
+1
  , t : 1 abcdef
@@ -29,32 +29,32 @@
 bcdefghij , h : 
-0
+1
  , t : 1 abcdef
)r   r\  patch_splitMaxr'   rS  )r
   r]  	oldToTexts      r   testPatchSplitMaxzPatchTest.testPatchSplitMaxv  sc   ((%%3F
 	( lHH!!'*	

 ((%%`
 HH))'2	(DHH$9$9'$BC((%%T
 	( jHH!!'*	

 ((%%^^
 	( QHH!!'*	
r   c                 R   | j                   j                  dd      }| j                  d| j                   j                  |             | j                   j	                  |       | j                  d| j                   j                  |             | j                   j                  dd      }| j                  d| j                   j                  |             | j                   j	                  |       | j                  d| j                   j                  |             | j                   j                  d	d
      }| j                  d| j                   j                  |             | j                   j	                  |       | j                  d| j                   j                  |             y )Nr   testz@@ -0,0 +1,4 @@
+test
z3@@ -1,8 +1,12 @@
 %01%02%03%04
+test
 %01%02%03%04
XYXtestYz@@ -1,2 +1,6 @@
 X
+test
 Y
z/@@ -2,8 +2,12 @@
 %02%03%04X
+test
 Y%01%02%03
XXXXYYYYXXXXtestYYYYz#@@ -1,8 +1,12 @@
 XXXX
+test
 YYYY
z#@@ -5,8 +5,12 @@
 XXXX
+test
 YYYY
)r   r\  r'   rS  patch_addPadding)r
   r]  s     r   testPatchAddPaddingzPatchTest.testPatchAddPadding  sN   ((%%b&13TXX5J5J75ST!!'*EHH!!'*	
 ((%%dH5.0E0Eg0N	
 	!!'*AHH!!'*	
 ((%%j.A5txx7L7LW7U	
 	!!'*5txx7L7LW7U	
r   c                 h	   d| j                   _        d| j                   _        d| j                   _        | j                   j	                  dd      }| j                   j                  |d      }| j                  dg f|       | j                   j	                  dd      }| j                   j                  |d      }| j                  dddgf|       | j                   j                  |d      }| j                  d	ddgf|       | j                   j                  |d
      }| j                  d
ddgf|       | j                   j	                  dd      }| j                   j                  |d      }| j                  dddgf|       | j                   j	                  dd      }| j                   j                  |d      }| j                  dddgf|       d| j                   _        | j                   j	                  dd      }| j                   j                  |d      }| j                  dddgf|       d| j                   _        d| j                   _        d| j                   _        | j                   j	                  dd      }| j                   j                  |d      }| j                  dddgf|       d| j                   _        d| j                   _        | j                   j	                  dd      }| j                   j                  |      }| j                   j                  |d      }| j                  || j                   j                  |             | j                   j	                  dd      }| j                   j                  |      }| j                   j                  |d       | j                  || j                   j                  |             | j                   j	                  dd      }| j                   j                  |d       | j                  ddgf|       | j                   j	                  dd      }| j                   j                  |d      }| j                  ddgf|       | j                   j	                  dd      }| j                   j                  |d      }| j                  ddgf|       y ) Nr5  r   r   zHello world.rV  r[  Tz0The quick red rabbit jumps over the tired tiger.z0That quick red rabbit jumped over a tired tiger.r>  FHx1234567890123456789012345678901234567890123456789012345678901234567890yxabcyzRx123456789012345678901234567890-----++++++++++-----123456789012345678901234567890yzRx12345678901234567890---------------++++++++++---------------12345678901234567890yzUxabc12345678901234567890---------------++++++++++---------------12345678901234567890yg333333?r-  r   z8abcdefghijklmnopqrstuvwxyz--------------------1234567890zLabcXXXXXXXXXXdefghijklmnopqrstuvwxyz--------------------1234567YYYYYYYYYY890z8ABCDEFGHIJKLMNOPQRSTUVWXYZ--------------------1234567890zBABCDEFGHIJKLMNOPQRSTUVWXYZ--------------------1234567YYYYYYYYYY890rj  Woofrk  rl  rQ   y123r   x123)r   r6  r7  Patch_DeleteThresholdr\  patch_applyr'   rS  )r
   r]  rw   patchstrs       r   testPatchApplyzPatchTest.testPatchApply  sn   "&#& ),&((%%b"-((&&w?."-w7 ((%%::
 ((&&C
 	;dD\JG	

 ((&&G
 	?$NPW	

 ((&&E
 	=u~NPW	

 ((%%V
 ((&&`
 	'D$<0': ((%%V
 ((&&`
 	g 	
 *-&((%%V
 ((&&`
 	'D$<0':),& $' "#((%%FZ
 ((&&O
 	T 	
 $' "& ((%%b&188((1((&&w3488#8#8#AB ((%%:F
 88((1W&TU488#8#8#AB ((%%b&1Wb)&4&)73 ((%%dH5((&&w5(TF+W5 ((%%c62((&&w4&4&)73r   N)r   r   r   r  rN  rQ  rT  rY  r_  rh  rp  rz  r   r   r   rB  rB    s1    
*:	9
:AF&
P
>}4r   rB  __main__)r  	importlibosr   r  unittestpathabspath
parentPathrk   r   r   reloadTestCaser   r   r  rB  r   mainr   r   r   <module>r     s   "  	 
  WW__T"
SXXHHOOAz" % 	   ** "|! |~!_" _Dd4" d4N zHMMO r   