Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_struct.cpython-39.pyc

a

��g���@s�ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZejdkZ
dZdZefdd	�Zd
d�Zdd
�ZGdd�dej�ZGdd�dej�Zedkr�e��dS)�)�abcN)�support)�assert_python_ok�big)�b�B�h�H�i�I�l�L�q�Q�n�N)��@�=�<�>�!ccs4tD]*}|D] }|dvr"|dvr"q||fVqqdS)N�rr)rr)�
integer_codes)�
byteorders�code�	byteorder�r�,/usr/local/lib/python3.9/test/test_struct.py�iter_integer_formatss
rcCs|ddd�S)N���r)�srrr�string_reversesr"cCstr|St|�SdS�N)�ISBIGENDIANr")�valuerrr�bigendian_to_nativesr&c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zejd'd(��Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7S)8�
StructTestcCs |�t�dd�ddkt�dS)Nz=i�r)�assertEqual�struct�packr$��selfrrr�test_isbigendian"szStructTest.test_isbigendiancCs|�tjtjd�t�d�}|�|dt�d��d}d}t�|�}t�|�}|�|d|�|�tjtjdd�|�tjtjdddd�|�ttjftjdd�|�ttjftjdd�|�tjtjd	d
�t�ddd
�}|�tjtjd|�|�tjtjd|�dS)N�Zr
�Ziiizcbxxxxxxhhhhiillffd?z3c3b18x12h6i6l6f3d3?Zfoo�P�dsflap�iir(�)�assertRaisesr*�error�calcsizer)r+�	TypeError�unpack)r-Zsz�fmtZfmt3Zsz3r!rrr�test_consistence%s 


zStructTest.test_consistencec
Cs�d}d}d}d}d}d}d}d}dD]�}	d	D]�}
|	|
}
t�|
||||||||�	}t�|
|�\}}
}}}}}}|�||�|�|
|�|�||�|�||�|�||�|�td
|�td
|��|�td
|�td
|��|�||�q,q$dS)N�ar(�i��igo���!	@T)rrrrrr)z	xcbhilfd?z	xcBHILfd?�d)r*r+r9r)�int)r-�crrr
r�fr2�t�prefix�formatr!ZcpZbpZhp�ipZlp�fpZdp�tprrr�test_transitiveness:s*zStructTest.test_transitivenessc&Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"gd#d#d$fd%g#}|D]�\}}}}}d&||fd'||fd(||fd)|tr�|p�|ffD]X\}}t�||�}	|�|	|�|�t�|�t|	��t�||	�d*}
|
|kr�|�|�q�qXdS)+N)r@r<r<r<r)Zxcr<�arIr)Zcxr<�arJr)r!r<r<r<r)�0s�
helloworld�rMr()Z1srL�hrNr()Z9srL�	helloworlrOr()Z10srLrLrLr)Z11srL�helloworldrPr()Z20srL�helloworldrQr()r��rSr)ri������rTr)rrRrSrSr)r�rTrTr)r�����r)riD�����D�D�r)r	rVrWrXr)r	iD�rYrZr)r
�,�,���,r)r
�����������r)rr[r\r]r)r��b�wr_r`r)rr[r\r]r)rr^r_r`r)r
r[r\r]r)r
rar_r`r)rA�@s@s@r)r2rbs@s@r)rA��s�s�r)r2rcs�s�r)�?r�rer)rdr0�rfr()rdTrfrfrrdrer()rd)r(rfrfr(rrrrr)r$r*r+r)r7�lenr9�
assertTrue)r-Ztestsr:�argrZlilZasyZxfmt�exp�resZrevrrr�test_new_featuresRs\�(�zStructTest.test_new_featuresc
CsZddddddddddd�
}td�D]*\}}||}t�|�}|�|||�q"d}|D]>}dD]4}t�||d	�}t�||d�}	|�||	�q^qV|�t�d
�d�|�dt�d��|�dt�d��|�t�d�t�d
��|�t�d
�t�d��|�dt�d��|�t�d�t�d��|�t�d�t�d
��|�t�d�t�d��dS)Nr(r4��)
rrrr	r
rrr
rr�rrrr)ZbBZhHZiIZlL�nNZqQrrrrrr
rrr1)rr*r7r)ZassertLessEqual�assertGreaterEqual)
r-Z
expected_sizerrrD�sizeZnative_pairsZformat_pairZsigned_sizeZ
unsigned_sizerrr�
test_calcsize�s2�	
zStructTest.test_calcsizecsNddl�G���fdd�dtj��t�D] \}}||����}|��q(dS)Nrcs@eZdZ��fdd�Zejej�jfdd�Z�fdd�Z	�Z
S)z+StructTest.test_integers.<locals>.IntTestercs�t�|�jdd�||_|d|_|dd�|_|jtvrHtd|j��t�|�|_	|j	d|_
|jtd�vr�d|_d|j
d	|_
d|j
d	d	|_n:|jtd
�vr�d|_d|_
d|j
d	|_ntd
|j��dS)N�test_one)Z
methodNamer z"unrecognized packing byteorder: %srnZbhilqnTr4r(ZBHILQNFrzunrecognized format code: %s)�super�__init__rDrrr�
ValueErrorr*r7�bytesize�bitsize�tuple�signed�	min_value�	max_value)r-rD)�	IntTester�	__class__rrrv�s*

��z4StructTest.test_integers.<locals>.IntTester.__init__c	Ss.|j}|j|kr |jk�rnn�|}|jrD|dkrD|d|j>7}|�|d�d|}t|�d@rld|}|�d�}||�}d|jt|�|}|j	dks�|j	dvr�t
s�t|�}|�t|�|j�|||�}|�||�|||�d}|�||�|�
tjtf||d	|�n|�
tttjf|||�dS)
Nrr(z%x�0�asciirer)rrrrf)rDr|r}r{ryrqrg�encoderxrr$r"r)r5r*r6r8�
OverflowErrorrw)	r-�xr+r9�	unhexlifyrD�expected�gotZ	retrievedrrrrt�s>
�
��
��z4StructTest.test_integers.<locals>.IntTester.test_onecsddlm}g}t|jd�D]}|�d|>�qt|j�D]2}d}t|j�D]}|d>|d�B}qN|�|�q<|�ddtjd	g�|D]0}||fD] }d
D]}||}	|�	|	�q�q�q�Gdd�d�}
Gd
d�dt
�}Gdd�dt
�}|�tt
jft
j|jd�|�tt
jft
j|j|�|�tt
jft
j|jd�|�tt
jft
j|j|
��|�tt
jft
j|j|��|d�|d�|d�|d�|d�|d�fD].}
zt
��|
�Wn|�d�Yn0�q�|d�|d�|d�|ddi�|gd��fD] }
|�tt
jft
j|j|
��q�dS)Nr)�	randranger0r(rn�i,i`�
rm)r rr(c@seZdZdd�ZdS)zAStructTest.test_integers.<locals>.IntTester.run.<locals>.NotAnIntcSsdS�N�*rr,rrr�__int__szIStructTest.test_integers.<locals>.IntTester.run.<locals>.NotAnInt.__int__N)�__name__�
__module__�__qualname__r�rrrr�NotAnIntsr�c@seZdZdd�Zdd�ZdS)zBStructTest.test_integers.<locals>.IntTester.run.<locals>.IndexablecSs
||_dSr#��_value)r-r%rrrrvszKStructTest.test_integers.<locals>.IntTester.run.<locals>.Indexable.__init__cSs|jSr#r�r,rrr�	__index__szLStructTest.test_integers.<locals>.IntTester.run.<locals>.Indexable.__index__N)r�r�r�rvr�rrrr�	Indexablesr�c@seZdZdd�Zdd�ZdS)zAStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndexcSst�dSr#)r8r,rrrr�szKStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndex.__index__cSsdSr�rr,rrrr�szIStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndex.__int__N)r�r�r�r�r�rrrr�BadIndexsr�za stringy@E@�
�r�r>�z:integer code pack failed on object with '__index__' methodr<r�a)r(r4r0)�randomr��rangery�appendrx�extend�sys�maxsizert�objectr5r8r*r6r+rD�fail)r-r��valuesrjr
�val�j�baseZincrr�r�r�r��obj)rDrr�run�sh	��������z/StructTest.test_integers.<locals>.IntTester.run)r�r�r�rvr*r+r9r�rtr��
__classcell__r�r~�binasciirD)rrr~�s�
&r~)r��unittest�TestCaserr�)r-rrrBrr�r�
test_integers�szStructTest.test_integerscsT�fdd�}dD]>}dD]4}||}|tj|�|tj|d�|tj|d�qqdS)NcsP��tj��}||i|��Wd�n1s00Y��dt|j��dS)Nzbad char in struct format)r5r*r6�assertIn�str�	exception)�func�args�kwargs�cmr,rr�assertStructErrorEs,z2StructTest.test_nN_code.<locals>.assertStructErrorrprorrM)r*r7r+r9)r-r�rrrDrr,r�test_nN_codeCszStructTest.test_nN_codecCsHdD]>\}}}}t�||�}|�||�t�||�\}|�||�qdS)N))�p�abcrerM)Z1pr�rerM)Z2pr�sar<)Z3pr�sabsab)Z4p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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r*r+r)r9)r-r�inputr�Zexpectedbackr�rrr�test_p_codePs
	zStructTest.test_p_codecCs�tdd�D]�}d}||d|kr,|d}q||}t�d|�}t�d|�d}|�||�t�d|�}|�|t|��t�d|�d}|�||�q
d}t�|d	�}t�d|�}t�d|�d}|�||�d
}t�|d�}|�t	tjd|�dS)Nr(�!g�?rbz<frz>fi����hi����g)
r�r*r+r9r)r"�math�ldexpr5r�)r-r�ZdeltaZsmaller�packedZunpackedZ	bigpackedrrrr�test_705836`s(
zStructTest.test_705836cCslt�D]8\}}||}|�tjtj|d�|�tjtj|d�q|�tjtjdd�|�tjtjdd�dS)N��?g�?r1)rr5r*r6r+)r-rrrDrrr�test_1530559�szStructTest.test_1530559c	Cs�d}d}t�|�}ttfD]�}||�}|�|�|�d�|�|�|d�d�|�|�|d�d�td�D]&}|�|�||�|||d�f�qhtdt|�d	�D]}|�tj	|j||�q�qttfD]�}||�}|�t�||�d�|�t�||d�d�|�t�||d�d�td�D]*}|�t�|||�|||d�f��qtdt|�d	�D]}|�tj	tj|||��qXq�|�|j|dd
�d�dS)Ns	abcd01234Z4s)sabcdr4)scd01rm)s0123�r()�buffer�offset)
r*�Struct�bytes�	bytearrayr)�unpack_fromr�rgr5r6)r-�test_stringr:r!�cls�datar
rrr�test_unpack_from�s0
$(�zStructTest.test_unpack_fromcCs�d}t�dd�}d}t�|�}|�|d|�|��dt|��}|�||�|�|d|�|��dt|�d�}|�||dd�|�t�dd�}|�ttj	f|j|d|�|�ttj	f|j|d|�|}|�t
tj	ftjd	|d�dS)
N�Reykjavik rocks, eow!r�d                                                                                                    �21srr��
          r4rM)�arrayr*r��	pack_into�tobytesrgr)r5rwr6r8)r-r��writable_bufr:r!�from_buf�	small_bufZsbrrr�test_pack_into�s*
���zStructTest.test_pack_intocs�d}t�dd�}d��fdd�}||d|�|��dt|��}|�||�||d|�|��dt|�d�}|�||dd�|�t�dd	�}|�ttjf||d|�|�ttjf||d
|�dS)Nr�rr�r�cstj�g|�R�Sr#)r*r�)r��r:rr�<lambda>�rMz.StructTest.test_pack_into_fn.<locals>.<lambda>rr�r�r4)r�r�rgr)r5rwr*r6)r-r�r�r�r�r�rr�r�test_pack_into_fn�s"��zStructTest.test_pack_into_fncCs@t�dd�}td�}||fD]}t�d|�\}|�|d�qdS)Nrs4Vxz>IixV4)r��
memoryviewr*r9r))r-Zdata1Zdata2r�r%rrr�test_unpack_with_buffer�s
z"StructTest.test_unpack_with_bufferc	Cs�Gdd�dt�}td�dD�]X}dggddf}dgd	d
ddd
f}|dt|�}tj|g|�R�}t�||�}|dt|�}tj|g|�R�}	t�||	�}
|�t|�t|
��|�t|�t|��|D]}|�|�q�|
D]}|�|�q�t�|dd�}|�t|�t�	|d��t|�dk�r8|j|d|d�zt�|d|��Wnt
�ybYq0|�d|d�qdD]}
|�t�d|
�d��q|dS)Nc@seZdZdd�ZdS)z+StructTest.test_bool.<locals>.ExplodingBoolcSst�dSr#)�OSErrorr,rrr�__bool__�sz4StructTest.test_bool.<locals>.ExplodingBool.__bool__N)r�r�r�r�rrrr�
ExplodingBool�sr�z<>!=)rrrrr(�test�r lg���Ardz encoded bool is not one byte: %r)�msgz2Expected OSError: struct.pack(%r, ExplodingBool()))rf������z>?)r�rzrgr*r+r9r)ZassertFalserhr7r�r�)r-r�rCZfalse�trueZfalseFormatZpackedFalseZ
unpackedFalseZ
trueFormatZ
packedTrueZunpackedTruerBr�r@rrr�	test_bool�s>��zStructTest.test_boolcCsPd�tjd�}|�tjtj|�d�tjdtjd�}|�tjtj|�dS)Nz{}br(z{}b{}Hr4)rDr�r�r5r*r6r7)r-Z	hugecountZ
hugecount2rrr�test_count_overflow
szStructTest.test_count_overflowcCst�dd�}|�tjtjd�|�tjtjdd�|�tjtjd|d�|�tjtjd|d�|�tjtjdd�|�tjtjdd�|�tjtjd|dd�|�tjtjd|d�|�tjtjd	d
�|�tjtjd	d�|�tjtjd	|dd
�|�tjtjd	|d�dS)Nrr�Z12345rMrZc12345r��xZ14s42z
spam and eggss
spam and eggs)r�r5r*r6r+r9r�r�)r-�storerrr�test_trailing_counters*����z StructTest.test_trailing_countercCst�d�}|�d�dS)Nr
r3)r*r�rv�r-r!rrr�test_Struct_reinitialization*s
z'StructTest.test_Struct_reinitializationcCs8t�d�}|t�d�|d7}t�|t�|�|�dS)NZ2n3PZP3n0Pr()rZcalcobjsizer*r7�check_sizeofr�)r-Z
format_strZnumber_of_codesZ	totalsizerrrr�1s
zStructTest.check_sizeofcCs�tD]}|�|d�q|�dd�|�dd�|�dd�|�dd	�|�d
d�|�dd�|�dd�|�d
d�|�dd	�dS)Nr(Z	BHILfdspP�	A�BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBi��fdr4ZxxxxxxxxxxxxxxrZ100HZ187sZ20prKZ0c)rr�)r-rrrr�test__sizeof__8szStructTest.test__sizeof__cCs�d}|�tj|��$t�dtd�dd�Wd�n1s<0Yd}|�tj|��"t�dtd�d�Wd�n1s�0YdS)Nzkpack_into requires a buffer of at least 6 bytes for packing 1 bytes at offset 5 \(actual buffer size is 1\)rr(r�zounpack_from requires a buffer of at least 6 bytes for unpacking 1 bytes at offset 5 \(actual buffer size is 1\))�assertRaisesRegexr*r6r�r�r��r-Zregex1Zregex2rrr�test_boundary_error_messageFs�2�z&StructTest.test_boundary_error_messagecCstd�}|�tjd�� t�d|dd�Wd�n1s<0Y|�tjd�� t�d|dd�Wd�n1sz0Y|�tjd	��t�d|d�Wd�n1s�0Y|�tjd��t�d|d�Wd�n1s�0YdS)
Nr�z%no space to pack 4 bytes at offset -2�<I����{z*offset -11 out of range for 10-byte bufferz<Bi����z.not enough data to unpack 4 bytes at offset -2)r�r�r*r6r�r�)r-Z	byte_listrrr�0test_boundary_error_message_with_negative_offsetWs*�.�.�,�z;StructTest.test_boundary_error_message_with_negative_offsetcCs�dttjd�dttj�d}|�tj|��&t�dtd�tjd�Wd�n1s^0Ydttjd�d	ttj�d}|�tj|��$t�dtd�tj�Wd�n1s�0YdS)
Nz(pack_into requires a buffer of at least rmz% bytes for packing 4 bytes at offset z \(actual buffer size is 10\)r�r�r(z*unpack_from requires a buffer of at least z' bytes for unpacking 4 bytes at offset )	r�r�r�r�r*r6r�r�r�r�rrr�-test_boundary_error_message_with_large_offsetms(����4����z8StructTest.test_boundary_error_message_with_large_offsetcCsN|�t��t�dd�Wd�n1s,0Y|�t�dd�d�dS)Nrrr<)�a)r5r8r*r9r)r,rrr�test_issue29802s*zStructTest.test_issue29802cCs<t�d�}|�|jd�t�|j���}|�|j|j�dS)Nz=i2H)r*r�r)rDr�)r-r!�s2rrr�test_format_attr�s
zStructTest.test_format_attrcCsLd}td|�\}}}|�|d�|�|��d�|�d|�|�d|�dS)Nz�if 1:
            import struct

            class C:
                def __init__(self):
                    self.pack = struct.pack
                def __del__(self):
                    self.pack('I', -42)

            struct.x = C()
            z-crrMsException ignored in:s	C.__del__)rr)�rstripr�)r-r�rc�stdout�stderrrrr�)test_struct_cleans_up_at_runtime_shutdown�sz4StructTest.test_struct_cleans_up_at_runtime_shutdownc	CsFdD]<}|�tjd��t�|�Wd�q1s60YqdS)N)�z2irezembedded null character)r�r*r6r7r�rrr�test_issue35714�s
�zStructTest.test_issue35714N) r�r�r�r.r;rHrlrsr�r�r�r�r�r�r�r�r�r�r�r�r�r�rZcpython_onlyr�r�r�r�r�rrrrrrrr'!s:5"
!+

	r'c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�UnpackIteratorTestzD
    Tests for iterative unpacking (struct.Struct.iter_unpack).
    cs"�fdd�}t�d�}|�d�}||�|�d�}||���tj��|�d�Wd�n1sf0Y��tj��|�d�Wd�n1s�0Yt�d�}��tj��|�d�Wd�n1s�0Y��tj��|�d	�Wd�n1�s0YdS)
Ncs ��|tj���|tj�dSr#)ZassertIsInstancer�Iterator�Iterable)�itr,rr�_check_iterator�sz:UnpackIteratorTest.test_construct.<locals>._check_iterator�>ibcprMs1234567s123456s12345678rs12)r*r��iter_unpackr5r6)r-rr!rrr,r�test_construct�s


((
(z!UnpackIteratorTest.test_constructcCs$tt�d��d��}|�t|�dS)Nr
rM)�typer*r�rr5r8)r-Ziter_unpack_typerrr�test_uninstantiable�sz&UnpackIteratorTest.test_uninstantiablecCsrt�d�}ttdd��}|�|�}|�t|�d�|�t|�d�|�t|�d�|�tt|�|�tt|�dS)N�>IBr(��ir��i	r�)i
�)	r*r�r�r�rr)�nextr5�
StopIteration�r-r!rrrrr�test_iterate�s

zUnpackIteratorTest.test_iteratecCsft�d�}ttdd��}|�t|��}|�t|�d�|�t|�d�|�t	t|�|�t	t|�dS�Nrr(�rr)
r*r�r�r�rr�r)rr5rrrrr�test_arbitrary_buffer�s
z(UnpackIteratorTest.test_arbitrary_buffercCs�tj}t�d�}ttdd��}|�|�}|�||�d�t|�|�||�d�t|�|�||�d�t|�|�||�d�|�	t
t|�|�||�d�dS)Nrr(rr0r4r)�operator�length_hintr*r�r�r�rr)rr5r)r-Zlhr!rrrrr�test_length_hint�s

z#UnpackIteratorTest.test_length_hintcCsVt�dttdd���}|�t|�d�|�t|�d�|�tt|�|�tt|�dSr)r*rr�r�r)rr5r)r-rrrr�test_module_func�s
z#UnpackIteratorTest.test_module_funccCs(ddddddddtd	�fd
td�fdg
}|D]�\}}|ddd
�}|�|t�d|�d�|�|t�d|��|�|t�d|�d�|�|t�d|��tjdkr�|�|t�d|�d�|�|t�d|��q,|�|t�d|�d�|�|t�d|��q,gd�}|D]L\}}|�t�	t�d|�d��|�t�	t�d|ddd
��d���qt�dtj
�}|�|dd@d�t�dtj
�}|�|dd@d�gd�}	|	D] \}}}|�|t�||���q�gd�}
|
D]\}}|�ttj||��q�dg}|D] \}}}|�|t�||���qdS)N)s<r�)s�rc)s�{g��@)s�?)sgp>)�g)s�g�s|z+infs�z-inf)sU5gT�?r �<er�>e�little�e))r$s�)r$s�)r$s��)r$s|)r$s~)r$s�r(�~))r%sg`>)r%r#g`>)r%r#gP>)r%��g�?)r%r)g������?)r%�g�?)r%r*r")r%s<g�?)r%�<g�?)r%r+g�?)r%�{�i�)r%r,i�)r%s�g`�)r%��g`�)r%r-gP�)r%s�g�)r%��g�)r%r.g�)r%s��i��))r%���@)r%��@)r%�u�<�7~)r%���)r%��)r%�u�<�7�)r$r/)r$r0)r$r1)r$r2)r$r3)r$r4)r%sg�g�����@)
�floatr)r*r9r+r�rrhr��isnan�nanr5r�)r-Z&format_bits_float__cleanRoundtrip_listZle_bitsrAZbe_bitsZformat_bits__nan_listZ
formatcode�bitsr�Z format_bits_float__rounding_listZ%format_bits_float__roundingError_listZ+format_bits_float__doubleRoundingError_listrrr�test_half_float�sP

�

	*�z"UnpackIteratorTest.test_half_floatN)r�r�r��__doc__rrrrr r!r9rrrrr�s
	r�__main__)�collectionsrr�r�rr�r*r�r�rZtest.support.script_helperrrr$rrrr"r&r�r'rr��mainrrrr�<module>s0
2

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists