File: float.rs

package info (click to toggle)
rust-rmp 0.8.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 396 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 490 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use rmp::encode::*;

#[test]
fn pass_pack_f32() {
    let mut buf = [0x00, 0x00, 0x00, 0x00, 0x00];

    write_f32(&mut &mut buf[..], 3.4028234e38_f32).ok().unwrap();

    assert_eq!([0xca, 0x7f, 0x7f, 0xff, 0xff], buf);
}

#[test]
fn pass_pack_f64() {
    use std::f64;

    let mut buf = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];

    write_f64(&mut &mut buf[..], f64::INFINITY).ok().unwrap();

    assert_eq!([0xcb, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], buf);
}