Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_struct.cpython-310.pyc
o

�9j�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZejdkZdZdZefd	d
�Zdd�Zd
d�ZGdd�dej�ZGdd�dej�Zedkrke��dSdS)�)�abcN)�support)�
import_helper)�assert_python_ok�big)�b�B�h�H�i�I�l�L�q�Q�n�N)��@�=�<�>�!ccs6�tD]}|D]}|dvr|dvrq||fVqqdS)N�rr)rr)�
integer_codes)�
byteorders�code�	byteorder�r�'/usr/lib/python3.10/test/test_struct.py�iter_integer_formatss���r cCs|ddd�S)N���r)�srrr�string_reversesr#cCstr|St|�S�N)�ISBIGENDIANr#)�valuerrr�bigendian_to_nativesr'c@seZdZdd�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�Zejd7d8��Z d9d:�Z!d;S)<�
StructTestcCs |�t�dd�ddkt�dS)Nz=i�r)�assertEqual�struct�packr%��selfrrr�test_isbigendian%s zStructTest.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��iiizcbxxxxxxhhhhiillffd?z3c3b18x12h6i6l6f3d3?�foo�P�dsflap�iir)�)�assertRaisesr+�error�calcsizer*r,�	TypeError�unpack)r.�sz�fmt�fmt3�sz3r"rrr�test_consistence(s 


zStructTest.test_consistencec
Cs�d}d}d}d}d}d}d}d}dD]f}	d	D]a}
|	|
}
t�|
||||||||�	}t�|
|�\}}
}}}}}}|�||�|�|
|�|�||�|�||�|�||�|�td
|�td
|��|�td
|�td
|��|�||�qqdS)N�ar)�i��igo���!	@T)rrrrrr)z	xcbhilfd?z	xcBHILfd?�d)r+r,r<r*�int)r.�crr	rr
�fr5�t�prefix�formatr"�cp�bp�hp�ip�lp�fp�dp�tprrr�test_transitiveness=s.��zStructTest.test_transitivenesscCs@gd�d�d�d�d�d�d�d�d	�d
�d�d�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"gd#d#d$f�d%�}|D]N\}}}}}d&||fd'||fd(||fd)|trl|pm|ffD],\}}t�||�}	|�|	|�|�t�|�t|	��t�||	�d*}
|
|kr�|�|�qpqOdS)+N)rFrBrBrBr)�xcrB�arUr)�cxrB�arWr)r"rBrBrBr)�0s�
helloworld�rZr))�1srY�hr\r))�9srY�	helloworlr^r))�10srYrYrYr)�11srY�helloworldrar))�20srY�helloworldrcr))r��rer)ri������rfr)rrdrerer)r�rfrfr)r	�����r)r	iD�����D�D�r)r
rhrirjr)r
iD�rkrlr)r�,�,���,r)r�����������r)rrmrnror)r��b�wrqrrr)r
rmrnror)r
rprqrrr)rrmrnror)rrsrqrrr)rG�@s@s@r)r5rts@s@r)rG��s�s�r)r5rus�s�r)�?r�rwr)rvr1�rxr))rvTrxrxrrvrwr))rv)r)rxrxr)rrrrr)r%r+r,r*r:�lenr<�
assertTrue)r.�testsr>�argr�lil�asy�xfmt�exp�res�revrrr�test_new_featuresUs���������	�
���
������������������!�"�#�$�%�(�
���zStructTest.test_new_featuresc
CsZddddddddddd�
}td�D]\}}||}t�|�}|�|||�qd}|D]}dD]}t�||d	�}t�||d�}	|�||	�q/q+|�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)r7��)
rrr	r
rrr
rrr�rrrr)�bB�hH�iI�lL�nN�qQrrrr	r
rrrr4)r r+r:r*�assertLessEqual�assertGreaterEqual)
r.�
expected_sizerrrJ�size�native_pairs�format_pair�signed_size�
unsigned_sizerrr�
test_calcsize�s4�	
�zStructTest.test_calcsizecsNddl�G���fdd�dtj��t�D]\}}||����}|��qdS)Nrcs@eZdZ��fdd�Zejej�jfdd�Z�fdd�Z	�Z
S)z+StructTest.test_integers.<locals>.IntTestercs�t�|�jdd�||_|d|_|dd�|_|jtvr$td|j��t�|�|_	|j	d|_
|jtd�vrOd|_d|j
d	|_
d|j
d	d	|_dS|jtd
�vrfd|_d|_
d|j
d	|_dStd
|j��)N�test_one)�
methodNamer!z"unrecognized packing byteorder: %sr��bhilqnTr7r)�BHILQNFrzunrecognized format code: %s)�super�__init__rJrrr�
ValueErrorr+r:�bytesize�bitsize�tuple�signed�	min_value�	max_value)r.rJ)�	IntTester�	__class__rrr��s*

��z4StructTest.test_integers.<locals>.IntTester.__init__c	Ss.|j}|j|kr|jkr�nnx|}|jr!|dkr!|d|j>7}|�|d�d|}t|�d@r5d|}|�d�}||�}d|jt|�|}|j	dksU|j	dvrYt
sYt|�}|�t|�|j�|||�}|�||�|||�d}|�||�|�
tjtf||d	|�dS|�
tttjf|||�dS)
Nrr)z%x�0�asciirwr)rrrrx)rJr�r�r�r�r�ry�encoder�rr%r#r*r8r+r9r;�
OverflowErrorr�)	r.�xr,r<�	unhexlifyrJ�expected�got�	retrievedrrrr��s8
�

��z4StructTest.test_integers.<locals>.IntTester.test_onecsddlm}g}t|jd�D]	}|�d|>�qt|j�D]}d}t|j�D]
}|d>|d�B}q'|�|�q|�ddtjd	g�|D]}||fD]}d
D]}||}	|�	|	�qPqLqEGdd�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
��|
�Wq�|�d�Yq�|d�|d�|d�|ddi�|gd��fD]}
|�tt
jft
j|j|
�q�dS)Nr)�	randranger1r)r��i,i`�
r�)r!rr)c@�eZdZdd�ZdS)zAStructTest.test_integers.<locals>.IntTester.run.<locals>.NotAnIntcS�dS�N�*rr-rrr�__int__�zIStructTest.test_integers.<locals>.IntTester.run.<locals>.NotAnInt.__int__N)�__name__�
__module__�__qualname__r�rrrr�NotAnInt
�r�c@�eZdZdd�Zdd�ZdS)zBStructTest.test_integers.<locals>.IntTester.run.<locals>.IndexablecSs
||_dSr$��_value)r.r&rrrr�s
zKStructTest.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�r�r�rrrr�	Indexable�r�c@r�)zAStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndexcS�t�r$)r;r-rrrr�r�zKStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndex.__index__cSr�r�rr-rrrr�r�zIStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndex.__int__N)r�r�r�r�r�rrrr�BadIndexr�r�za stringy@E@�
�r�rD�z:integer code pack failed on object with '__index__' methodrBr�a)r)r7r1)�randomr��ranger��appendr��extend�sys�maxsizer��objectr8r;r+r9r,rJ�fail)r.r��valuesr�r�val�j�base�incrr�r�r�r��obj)rJrr�run�sn��	���������z/StructTest.test_integers.<locals>.IntTester.run)r�r�r�r�r+r,r<r�r�r��
__classcell__r�r��binasciirJ)r�rr��s
�&r�)r��unittest�TestCaser r�)r.rrrHrr�r�
test_integers�s
�zStructTest.test_integerscsT�fdd�}dD]}dD]}||}|tj|�|tj|d�|tj|d�qqdS)NcsP��tj��}||i|��Wd�n1swY��dt|j��dS)Nzbad char in struct format)r8r+r9�assertIn�str�	exception)�func�args�kwargs�cmr-rr�assertStructErrorHs�z2StructTest.test_nN_code.<locals>.assertStructErrorr�r�rrZ)r+r:r,r<)r.r�rrrJrr-r�test_nN_codeFs��zStructTest.test_nN_codecCsHdD]\}}}}t�||�}|�||�t�||�\}|�||�qdS)N))�p�abcrwrZ)�1pr�rwrZ)�2pr�sarB)�3pr�sabsab)�4pr�sabcr�)�5pr�sabcr�)�6pr�sabcr�)�1000ps�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxs�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r+r,r*r<)r.r�inputr��expectedbackr�rrr�test_p_codeSs	�zStructTest.test_p_codecCstdd�D]L}d}||d|kr|d}||d|ks||}t�d|�}t�d|�d}|�||�t�d|�}|�|t|��t�d|�d}|�||�qd}t�|d	�}t�d|�}t�d|�d}|�||�d
}t�|d�}|�t	tjd|�dS)Nr)�!g�?rtz<frz>fi����hi����g)
r�r+r,r<r*r#�math�ldexpr8r�)r.r��delta�smaller�packed�unpacked�	bigpackedrrrr�test_705836cs*�zStructTest.test_705836cCslt�D]\}}||}|�tjtj|d�|�tjtj|d�q|�tjtjdd�|�tjtjdd�dS)N��?g�?r4)r r8r+r9r,)r.rrrJrrr�test_1530559�szStructTest.test_1530559c	Cs�d}d}t�|�}ttfD]Q}||�}|�|�|�d�|�|�|d�d�|�|�|d�d�td�D]}|�|�||�|||d�f�q4tdt|�d	�D]}|�tj	|j||�qQq
ttfD]V}||�}|�t�||�d�|�t�||d�d�|�t�||d�d�td�D]}|�t�|||�|||d�f�q�tdt|�d	�D]
}|�tj	tj|||�q�qc|�|j|dd
�d�dS)Ns	abcd01234�4s)sabcdr7)scd01r�)s0123�r))�buffer�offset)
r+�Struct�bytes�	bytearrayr*�unpack_fromr�ryr8r9)r.�test_stringr>r"�cls�datarrrr�test_unpack_from�s4
$�&��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��
          r7rZ)�arrayr+r�	pack_into�tobytesryr*r8r�r9r;)r.r�writable_bufr>r"�from_buf�	small_buf�sbrrr�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
rrrcstj�g|�R�Sr$)r+r)r��r>rr�<lambda>�sz.StructTest.test_pack_into_fn.<locals>.<lambda>rr�r
r7)rrryr*r8r�r+r9)r.rrrrrrrr�test_pack_into_fn�s"��zStructTest.test_pack_into_fncCs@t�dd�}td�}||fD]}t�d|�\}|�|d�qdS)Nrs4Vxz>IixV4)r�
memoryviewr+r<r*)r.�data1�data2rr&rrr�test_unpack_with_buffer�s�z"StructTest.test_unpack_with_bufferc	Cs�Gdd�dt�}td�dD]�}dggddf}dgd	d
ddd
f}|dt|�}tj|g|�R�}t�||�}|dt|�}tj|g|�R�}	t�||	�}
|�t|�t|
��|�t|�t|��|D]}|�|�qd|
D]}|�|�qnt�|dd�}|�t|�t�	|d��t|�dkr�|j|d|d�zt�|d|��Wn	t
y�Yqw|�d|d�qdD]
}
|�t�d|
�d�q�dS)Nc@r�)z+StructTest.test_bool.<locals>.ExplodingBoolcSr�r$)�OSErrorr-rrr�__bool__�r�z4StructTest.test_bool.<locals>.ExplodingBool.__bool__N)r�r�r�rrrrr�
ExplodingBool�r�rz<>!=)rrrrr)�test�r!lg���Arvz encoded bool is not one byte: %r)�msgz2Expected OSError: struct.pack(%r, ExplodingBool()))rx������z>?)r�r�ryr+r,r<r*�assertFalserzr:rr�)r.rrI�false�true�falseFormat�packedFalse�
unpackedFalse�
trueFormat�
packedTrue�unpackedTruerHr�rFrrr�	test_bool�sB����zStructTest.test_boolcCsPd�tjd�}|�tjtj|�d�tjdtjd�}|�tjtj|�dS)Nz{}br)z{}b{}Hr7)rJr�r�r8r+r9r:)r.�	hugecount�
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�12345rZr�c12345r��x�14s42z
spam and eggss
spam and eggs)rr8r+r9r,r<rr)r.�storerrr�test_trailing_counters*����z StructTest.test_trailing_countercCst�d�}|�d�dS)Nrr6)r+rr��r.r"rrr�test_Struct_reinitialization-s
z'StructTest.test_Struct_reinitializationcCs8t�d�}|t�d�|d7}t�|t�|�|�dS)N�2n3P�P3n0Pr))r�calcobjsizer+r:�check_sizeofr)r.�
format_str�number_of_codes�	totalsizerrrr?4s
zStructTest.check_sizeofcCs�tD]}|�|d�q|�dd�|�dd�|�dd�|�dd	�|�d
d�|�dd�|�dd�|�d
d�|�dd	�dS)Nr)�	BHILfdspP�	��BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB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BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBi��fdr7�xxxxxxxxxxxxxxr�100H�187s�20prX�0c)rr?)r.rrrr�test__sizeof__;szStructTest.test__sizeof__cCs�d}|�tj|��t�dtd�dd�Wd�n1swYd}|�tj|��t�dtd�d�Wd�dS1sAwYdS)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+r9rrr�r.�regex1�regex2rrr�test_boundary_error_messageIs���"�z&StructTest.test_boundary_error_messagecCstd�}|�tjd��t�d|dd�Wd�n1swY|�tjd��t�d|dd�Wd�n1s=wY|�tjd	��t�d|d�Wd�n1s[wY|�tjd��t�d|d�Wd�dS1szwYdS)
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)rrMr+r9rr)r.�	byte_listrrr�0test_boundary_error_message_with_negative_offsetZs2�������"�z;StructTest.test_boundary_error_message_with_negative_offsetcCs�dttjd�dttj�d}|�tj|��t�dtd�tjd�Wd�n1s/wYdttjd�d	ttj�d}|�tj|��t�dtd�tj�Wd�dS1scwYdS)
Nz(pack_into requires a buffer of at least r�z% bytes for packing 4 bytes at offset z \(actual buffer size is 10\)rRr�r)z*unpack_from requires a buffer of at least z' bytes for unpacking 4 bytes at offset )	r�r�r�rMr+r9rrrrNrrr�-test_boundary_error_message_with_large_offsetps,���������"�z8StructTest.test_boundary_error_message_with_large_offsetcCsN|�t��t�dd�Wd�n1swY|�t�dd�d�dS)NrrrB)�a)r8r;r+r<r*r-rrr�test_issue29802�s�zStructTest.test_issue29802cCs<t�d�}|�|jd�t�|j���}|�|j|j�dS)Nz=i2H)r+rr*rJr�)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-crrZsException 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_shutdowncCs:t�d�}t�|�}|�d�~t��|�|�d�dS)N�_structrz(_struct module was not garbage collected)r�import_fresh_module�weakref�refr:�gc�collect�assertIsNone)r.�_struct_module�
module_refrrr�'test__struct_reference_cycle_cleaned_up�s


�z2StructTest.test__struct_reference_cycle_cleaned_upc
Cs�tj}tt�dd��}||fD]0}|j|d�� |�t��d|_Wd�n1s+wYWd�n1s:wYqdS)Nrr6)rr))r+r�type�iter_unpack�subTestr8r;r�)r.r�unpack_iteratorrrrr�test__struct_types_immutable�s�����z'StructTest.test__struct_types_immutablec	CsFdD]}|�tjd��
t�|�Wd�n1swYqdS)N)�z2irwzembedded null character)rMr+r9r:r:rrr�test_issue35714�s����zStructTest.test_issue35714N)"r�r�r�r/rArSr�r�r�r�r�r�r�r	rrrr0r3r9r;r?r�cpython_onlyrLrQrVrWrYr[r`rjrorqrrrrr($sB5"
!+

	
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�n1s3wY��tj��
|�d�Wd�n1sNwYt�d�}��tj��
|�d�Wd�n1snwY��tj��|�d	�Wd�dS1s�wYdS)
Ncs ��|tj���|tj�dSr$)�assertIsInstancer�Iterator�Iterable)�itr-rr�_check_iterator�sz:UnpackIteratorTest.test_construct.<locals>._check_iterator�>ibcprZs1234567s123456s12345678rs12)r+rrlr8r9)r.rxr"rwrr-r�test_construct�s&


��
�"�z!UnpackIteratorTest.test_constructcCs$tt�d��d��}|�t|�dS)NryrZ)rkr+rrlr8r;)r.�iter_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+rrr�rlr*�nextr8�
StopIteration�r.r"rrwrrr�test_iterate�s

zUnpackIteratorTest.test_iteratecCsft�d�}ttdd��}|�t|��}|�t|�d�|�t|�d�|�t	t|�|�t	t|�dS�Nr}r)�rr�)
r+rrr�rlrr*r�r8r�r�rrr�test_arbitrary_buffer�s
z(UnpackIteratorTest.test_arbitrary_buffercCs�tj}t�d�}ttdd��}|�|�}|�||�d�t|�|�||�d�t|�|�||�d�t|�|�||�d�|�	t
t|�|�||�d�dS)Nr}r)r~r1r7r)�operator�length_hintr+rrr�rlr*r�r8r�)r.�lhr"rrwrrr�test_length_hint�s

z#UnpackIteratorTest.test_length_hintcCsVt�dttdd���}|�t|�d�|�t|�d�|�tt|�|�tt|�dSr�)r+rlrr�r*r�r8r�)r.rwrrr�test_module_funcs
z#UnpackIteratorTest.test_module_funccCs ddddddddtd	�fd
td�fdg
}|D]i\}}|ddd
�}|�|t�d|�d�|�|t�d|��|�|t�d|�d�|�|t�d|��tjdkri|�|t�d|�d�|�|t�d|��q|�|t�d|�d�|�|t�d|��qgd�}|D]%\}}|�t�	t�d|�d��|�t�	t�d|ddd
��d��q�t�dtj
�}|�|dd@d�t�dtj
�}|�|dd@d�gd�}	|	D]\}}}|�|t�||��q�gd�}
|
D]
\}}|�ttj||�q�dg}|D]\}}}|�|t�||��q�dS)N)s<r�)s�ru)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�r�)r�r�)r�r�)r�r�)r�r�)r�sg�g�����@)
�floatr*r+r<r,r�rrzr��isnan�nanr8r�)r.�&format_bits_float__cleanRoundtrip_list�le_bitsrG�be_bits�format_bits__nan_list�
formatcode�bitsr�� format_bits_float__rounding_list�%format_bits_float__roundingError_list�+format_bits_float__doubleRoundingError_listrrr�test_half_floatsR

�

	(��z"UnpackIteratorTest.test_half_floatN)r�r�r��__doc__rzr|r�r�r�r�r�rrrrrs�s
	rs�__main__)�collectionsrrrer�r�r�r+r�rcr r�test.supportr�test.support.script_helperrrr%rrr r#r'r�r(rsr��mainrrrr�<module>s:
)2�

Youez - 2016 - github.com/yon3zu
LinuXploit