summaryrefslogtreecommitdiffstats
path: root/vendor/serde_json/tests/regression/issue520.rs
blob: 9ed367731b614e3611ee32ce065a96437fd10c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#![allow(clippy::float_cmp)]

use serde_derive::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "type", content = "data")]
enum E {
    Float(f32),
}

#[test]
fn test() {
    let e = E::Float(159.1);
    let v = serde_json::to_value(e).unwrap();
    let e = serde_json::from_value::<E>(v).unwrap();

    match e {
        E::Float(f) => assert_eq!(f, 159.1),
    }
}