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
67
68
69
70
71
#![allow(dead_code)]
use crate::transformation::*;
use std::cmp::Ordering;
#[derive(Debug, Clone, PartialEq)]
pub struct MtriX {
pub serial_number: usize,
pub transformation: TransformationMatrix,
pub contained: bool,
}
impl MtriX {
pub fn new(
serial_number: usize,
transformation: TransformationMatrix,
contained: bool,
) -> Self {
MtriX {
serial_number,
transformation,
contained,
}
}
}
impl PartialOrd for MtriX {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.serial_number.cmp(&other.serial_number))
}
}
impl Default for MtriX {
fn default() -> Self {
Self::new(0, TransformationMatrix::identity(), false)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_equality() {
let a = MtriX::default();
let b = MtriX::new(0, TransformationMatrix::identity(), false);
let c = MtriX::new(1, TransformationMatrix::identity(), true);
assert_eq!(a, b);
assert_ne!(a, c);
assert_ne!(b, c);
assert!(a < c);
}
#[test]
fn test_accessors() {
let a = MtriX::default();
assert_eq!(a.contained, false);
assert_eq!(a.serial_number, 0);
assert_eq!(a.transformation, TransformationMatrix::identity());
}
#[test]
fn test_debug() {
let a = MtriX::default();
format!("{:?}", a);
}
}