@@ -84,9 +84,13 @@ def id_fn(val: bytes | str) -> str:
8484 ],
8585 ids = id_fn ,
8686)
87- def test_read_sid (binary_sid : bytes | BinaryIO , endian : str , swap_last : bool , readable_sid : str ) -> None :
87+ def test_read_write_sid (binary_sid : bytes | BinaryIO , endian : str , swap_last : bool , readable_sid : str ) -> None :
8888 assert readable_sid == sid .read_sid (binary_sid , endian , swap_last )
8989
90+ if isinstance (binary_sid , io .BytesIO ):
91+ binary_sid = binary_sid .getvalue ()
92+ assert binary_sid == sid .write_sid (readable_sid , endian , swap_last )
93+
9094
9195@pytest .mark .benchmark
9296@pytest .mark .parametrize (
@@ -105,3 +109,22 @@ def test_read_sid(binary_sid: bytes | BinaryIO, endian: str, swap_last: bool, re
105109)
106110def test_read_sid_benchmark (benchmark : BenchmarkFixture , binary_sid : bytes , swap_last : bool ) -> None :
107111 benchmark (sid .read_sid , binary_sid , "<" , swap_last )
112+
113+
114+ @pytest .mark .benchmark
115+ @pytest .mark .parametrize (
116+ ("readable_sid" , "swap_last" ),
117+ [
118+ (
119+ "S-1-5-21-123456789-268435456-500" ,
120+ False ,
121+ ),
122+ (
123+ "S-1-5-21-123456789-268435456-500" ,
124+ True ,
125+ ),
126+ ],
127+ ids = lambda x : x if isinstance (x , str ) else str (x ),
128+ )
129+ def test_write_sid_benchmark (benchmark : BenchmarkFixture , readable_sid : str , swap_last : bool ) -> None :
130+ benchmark (sid .write_sid , readable_sid , "<" , swap_last )
0 commit comments