@@ -179,3 +179,51 @@ def test_dab_cbor_encode_map_int_key() -> None:
179179 libipld .encode_dag_cbor (obj )
180180
181181 assert 'Map keys must be strings' in str (exc_info .value )
182+
183+
184+ def test_dag_cbor_decode_nan_f64_error () -> None :
185+ # fb7ff8000000000000 - IEEE 754 double precision NaN
186+ with pytest .raises (ValueError ) as exc_info :
187+ libipld .decode_dag_cbor (bytes .fromhex ('fb7ff8000000000000' ))
188+
189+ assert 'number out of range for f64' in str (exc_info .value ).lower ()
190+
191+
192+ def test_dag_cbor_decode_positive_infinity_f64_error () -> None :
193+ # fb7ff0000000000000 - IEEE 754 double precision positive infinity
194+ with pytest .raises (ValueError ) as exc_info :
195+ libipld .decode_dag_cbor (bytes .fromhex ('fb7ff0000000000000' ))
196+
197+ assert 'number out of range for f64' in str (exc_info .value ).lower ()
198+
199+
200+ def test_dag_cbor_decode_negative_infinity_f64_error () -> None :
201+ # fbfff0000000000000 - IEEE 754 double precision negative infinity
202+ with pytest .raises (ValueError ) as exc_info :
203+ libipld .decode_dag_cbor (bytes .fromhex ('fbfff0000000000000' ))
204+
205+ assert 'number out of range for f64' in str (exc_info .value ).lower ()
206+
207+
208+ def test_dag_cbor_decode_nan_f32_error () -> None :
209+ # fa7fc00000 - IEEE 754 single precision NaN
210+ with pytest .raises (ValueError ) as exc_info :
211+ libipld .decode_dag_cbor (bytes .fromhex ('fa7fc00000' ))
212+
213+ assert 'number out of range for f32' in str (exc_info .value ).lower ()
214+
215+
216+ def test_dag_cbor_decode_positive_infinity_f32_error () -> None :
217+ # fa7f800000 - IEEE 754 single precision positive infinity
218+ with pytest .raises (ValueError ) as exc_info :
219+ libipld .decode_dag_cbor (bytes .fromhex ('fa7f800000' ))
220+
221+ assert 'number out of range for f32' in str (exc_info .value ).lower ()
222+
223+
224+ def test_dag_cbor_decode_negative_infinity_f32_error () -> None :
225+ # faff800000 - IEEE 754 single precision negative infinity
226+ with pytest .raises (ValueError ) as exc_info :
227+ libipld .decode_dag_cbor (bytes .fromhex ('faff800000' ))
228+
229+ assert 'number out of range for f32' in str (exc_info .value ).lower ()
0 commit comments