tf_rosrust/
tf_graph_node.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub(crate) struct TfGraphNode {
    pub(crate) child: String,
    pub(crate) parent: String,
}

#[cfg(test)]
mod test {
    use std::collections::HashMap;

    use crate::tf_graph_node::TfGraphNode;

    #[test]
    fn test() {
        let mut hash_map = HashMap::new();
        hash_map.insert(
            TfGraphNode {
                child: "child0".to_owned(),
                parent: "parent".to_owned(),
            },
            0,
        );
        assert_eq!(hash_map.len(), 1);
        hash_map.insert(
            TfGraphNode {
                child: "child0".to_owned(),
                parent: "parent".to_owned(),
            },
            1,
        );
        assert_eq!(hash_map.len(), 1);

        let mut hash_map = HashMap::new();
        hash_map.insert(
            TfGraphNode {
                child: "child0".to_owned(),
                parent: "parent0".to_owned(),
            },
            0,
        );
        assert_eq!(hash_map.len(), 1);
        hash_map.insert(
            TfGraphNode {
                child: "parent0".to_owned(),
                parent: "child0".to_owned(),
            },
            0,
        );
        assert_eq!(hash_map.len(), 2);
        hash_map.insert(
            TfGraphNode {
                child: "child0".to_owned(),
                parent: "parent1".to_owned(),
            },
            0,
        );
        assert_eq!(hash_map.len(), 3);
    }
}