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
60
61
62
63
64
65
66
use crate::graph::Edge;

#[derive(Clone)]
pub struct Node {
    pub id: usize,
    pub edges: Vec<Edge>,
}

impl Node {
    pub fn from(id: usize, edges: Vec<Edge>) -> Node {
        return Node {
            id,
            edges,
        };
    }
}

pub struct Position3D {
    pub x: f32,
    pub y: f32,
    pub z: f32,
}

impl Position3D {
    pub fn zeroed() -> Position3D {
        return Position3D {
            x: 0.0,
            y: 0.0,
            z: 0.0,
        };
    }

    pub fn from(x: f32, y: f32, z: f32) -> Position3D {
        return Position3D {
            x,
            y,
            z,
        };
    }
}

#[test]
fn create_node_should_succeed() {
    let node = Node::from(1, vec![]);

    assert_eq!(1, node.id);
    assert!(node.edges.is_empty());
}

#[test]
fn create_zeroed_position_should_succeed() {
    let position = Position3D::zeroed();

    assert_eq!(0.0, position.x);
    assert_eq!(0.0, position.y);
    assert_eq!(0.0, position.z);
}

#[test]
fn create_position_should_succeed() {
    let position = Position3D::from(0.1, 0.2, 0.3);

    assert_eq!(0.1, position.x);
    assert_eq!(0.2, position.y);
    assert_eq!(0.3, position.z);
}