
    ;eR                        d Z ddlmZ ddlmZmZ ddlZddlZddlZ G d dej	                  Z
 G d dej	                  Zed	k    r@ eej                  d
k    r ej        ej        d
                     ej                     dS dS )aT  
These tests are meant to exercise that requests to create objects bigger
than what the address space allows are properly met with an OverflowError
(rather than crash weirdly).

Primarily, this means 32-bit builds with at least 2 GiB of available memory.
You need to pass the -M option to regrtest (e.g. "-M 2.1G") for tests to
be enabled.
    )support)bigaddrspacetestMAX_Py_ssize_tNc                   P    e Zd Zed             Zed             Zed             ZdS )	BytesTestc                     	 dt           dz
  z  }|                     t          t          j        |d           d }d S # d }w xY wN   x   s   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r   assertRaisesOverflowErroroperatoraddselfxs     -/usr/lib/python3.11/test/test_bigaddrspace.pytest_concatzBytesTest.test_concat   sH    
	,-AmX\1jIIIAAAAHHHH   4: >c                    	 dt           dz
  z  }|                     t                    5 }|dz   }d d d            n# 1 swxY w Y   |                     t                    5 }|dz  }d d d            n# 1 swxY w Y   d }d S # d }w xY wr	   )r   r   r   r   r   cms      r   test_optimized_concatzBytesTest.test_optimized_concat    s   	,-A""=11 #R
N# # # # # # # # # # # # # # # ""=11 !Rj ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! AAAAHHHHsL   'B ;B ?B ?B  A2&B 2A66B 9A6:B Bc                     	 dt           dz
  z  }|                     t          t          j        |d           d }d S # d }w xY w)Nr
   r   )r   r   r   r   mulr   s     r   test_repeatzBytesTest.test_repeat/   sH    	,-AmX\1cBBBAAAAHHHHr   N)__name__
__module____qualname__r   r   r   r        r   r   r      sf                  r!   r   c                   T    e Zd ZdZed             Zed             Zed             ZdS )StrTest   c                     	 dt          t          d| j        z  z            z  }|                     t          t
          j        ||           d }d S # d }w xY wNr   皙?)intr   unicodesizer   MemoryErrorr   r   r   s     r   r   zStrTest.test_concat<   sZ    	c.S43C-CDEEEA k8<A>>>AAAAHHHH   A	A Ac                 :   	 dt          t          d| j        z  z            z  }|                     t                    5 }||z   }d d d            n# 1 swxY w Y   |                     t                    5 }||z  }d d d            n# 1 swxY w Y   d }d S # d }w xY wr&   )r(   r   r)   r   r*   r   s      r   r   zStrTest.test_optimized_concatG   s   	c.S43C-CDEEEA"";// 2E               "";// 2a               AAAAHHHHsR   <B AB AB AB 5B;B BB BB Bc                     	 dt          t          d| j        z  z            z  }|                     t          t
          j        |d           d }d S # d }w xY w)Nr   r'      )r(   r   r)   r   r*   r   r   r   s     r   r   zStrTest.test_repeatV   sX    	c.S43C-CDEEEAk8<A>>>AAAAHHHHr+   N)r   r   r   r)   r   r   r   r   r    r!   r   r#   r#   8   sk        K          r!   r#   __main__   )__doc__testr   test.supportr   r   unittestr   sysTestCaser   r#   r   lenargvset_memlimitmainr    r!   r   <module>r;      s          9 9 9 9 9 9 9 9   



" " " " "! " " "J$ $ $ $ $h $ $ $N z
s38}}qSXa[)))HMOOOOO r!   