gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definiciones

⎇ dff2beccf08bad5ea2c726f3b0b53b02ab2a68af tests/serde.rs Rust · 54 líneas · 1.3 KB Historia Quién tocó qué crudo

Fix serde feature with Units trait dff2beccf · Nico Burns ·

1#[cfg(test)]
2#[cfg(feature = "serde")]
3mod serde {
4    use serde_json::{self, Value};
5    use taffy::{DefaultUnits, Style};
6
7    #[test]
8    fn serde_can_serialize() {
9        let style: Style<DefaultUnits> = Style::DEFAULT;
10        let _ = serde_json::to_string(&style).unwrap();
11    }
12
13    #[test]
14    fn serde_can_deserialize_partial_values() {
15        use serde_json;
16        let json = r###"{
17            "inset": {
18                "left": { "Length": 22 },
19                "right": "Auto"
20            },
21            "size":
22            {
23                "width": { "Percent": 50 }
24            },
25            "min_size":
26            {
27                "height": { "Length": 10 }
28            },
29            "max_size":
30            {
31                "width": "Auto"
32            },
33            "margin":
34            {
35                "right": { "Length": 99.0 },
36                "bottom": { "Length": 99.0 }
37            },
38            "padding":
39            {
40                "left": { "Length": 99.0 }
41            },
42            "border":
43            {
44                "bottom": { "Length": 99.0 }
45            },
46            "gap": {
47                "width": { "Length": 99.0 }
48            },
49            "grid_row": { "start": "Auto" },
50            "grid_column": { "end": "Auto" }
51        }"###;
52        let _: Value = serde_json::from_str(&json).unwrap();
53    }
54}