tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1077HTML 1008Markdown 12TOML 83209 Definitions

⎇ main tests/hand_written/serde.rs Rust · 54 lines · 1.3 KB History Who touched what raw

Comine integration tests into one binary (#951) d803b72f9 · Nico Burns ·

1#[cfg(test)]
2#[cfg(feature = "serde")]
3mod serde {
4    use serde_json::{self, Value};
5    use taffy::style::Style;
6
7    #[test]
8    fn serde_can_serialize() {
9        let style: Style<String> = 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}