tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 709HTML 662Markdown 12TOML 62348 Sutichaykuna

⎇ morphorm tests/serde.rs Rust · 55 siq'ikuna · 1.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename `Points`/`points` to `Length`/`length` in many APIs (#459) 55abeaf2e · Simon Sapin ·

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