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
use GodotType;
use Variant;
use Vector2;

impl GodotType for Vector2 {
    fn to_variant(&self) -> Variant {
        Variant::from_vector2(self)
    }

    fn from_variant(variant: &Variant) -> Option<Self> {
        variant.try_to_vector2()
    }
}

godot_test!(
    test_vector2_variants {
        let vector = Vector2::new(1.0, 2.0);
        let variant = vector.to_variant();
        let vector_from_variant = Vector2::from_variant(&variant).unwrap();

        assert_eq!(vector, vector_from_variant);
    }
    );

#[cfg(test)]
mod tests {
    use super::Vector2;

    #[test]
    fn it_supports_equality() {
        assert_eq!(
            Vector2::new(1.0, 2.0),
            Vector2::new(1.0, 2.0)
            );
    }

    #[test]
    fn it_supports_inequality() {
        assert_ne!(
            Vector2::new(1.0, 10.0),
            Vector2::new(1.0, 2.0)
            );
    }
}