MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_to_hex

Function test_to_hex

crates/literal/src/float.rs:255–269  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253
254#[test]
255fn test_to_hex() {
256 use rand::Rng;
257 for _ in 0..20000 {
258 let bytes = rand::rng().random::<u64>();
259 let f = f64::from_bits(bytes);
260 if !f.is_finite() {
261 continue;
262 }
263 let hex = to_hex(f);
264 // println!("{} -> {}", f, hex);
265 let roundtrip = hexf_parse::parse_hexf64(&hex, false).unwrap();
266 // println!(" -> {}", roundtrip);
267 assert!(f == roundtrip, "{f} {hex} {roundtrip}");
268 }
269}
270
271#[test]
272fn test_remove_trailing_zeros() {

Callers

nothing calls this directly

Calls 3

to_hexFunction · 0.85
is_finiteMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected