enarx / ciborium

CBOR utilities
Other
243 stars 58 forks source link

[Bug]: Unit test failing #106

Closed rjzak closed 7 months ago

rjzak commented 7 months ago

Is there an existing issue for this?

Code of Conduct

Current Behaviour

---- codec::case_183 stdout ----
[f9, fe, 0] == [f9, fe, 0]
[f9, fe, 0] == [f9, 7e, 0]
thread 'codec::case_183' panicked at ciborium/tests/codec.rs:296:9:
assertion `left == right` failed
  left: [249, 254, 0]
 right: [249, 126, 0]

Seems to be this line case(-core::f64::NAN, val!(-core::f64::NAN), "f9fe00", false, Float), // Not In RFC in this file https://github.com/enarx/ciborium/blob/fdf3ec5c53256000f8e12f06c361ca18026a8d99/ciborium/tests/codec.rs#L223-L224

Expected Behaviour

Test should pass

Environment Information

Github CI

What's odd that it only seems to affect release tests on Stable, Beta, and Nightly releases of Rust. Debug tests on 1.70, Stable, Beta, Nightly pass.

Steps To Reproduce

  1. cargo +stable test --workspace --release
rjzak commented 7 months ago

Fixed in https://github.com/enarx/ciborium/pull/111

chrysn commented 3 months ago

Reliably doing NaN payloads is a lot of manual work as long as Rust doesn't preserve them in conversion (or offers an API that converts float preserving/truncating NaN sign, signalling status and payload).

I did the full preservation rules (as described in the cde draft) in my diagnostic notation parser -- definitely no recommendation to do it precisely this way (lots of cleanup and simplifications required), just to show that it can be done, and takes fiddling with .as_bits().