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
use dim::si;
pub type Watt = si::Watt<f32>;
#[derive(Debug, Copy, Clone)]
pub struct BeamPosition {
pub x: f32,
pub y: f32
}
impl BeamPosition {
pub fn new(x: f32, y: f32) -> BeamPosition {
BeamPosition {x: x, y: y}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn create_watt() {
let w = Watt::new(1.0);
}
#[test]
fn compare_watt() {
let w1 = Watt::new(1.0);
let w2 = Watt::new(2.0);
assert!(w2 > w1)
}
#[test]
fn equal_watt() {
let w1 = Watt::new(1.0);
let w2 = Watt::new(1.0);
assert!(w1 == w2)
}
#[test]
fn add_watt() {
let w1 = Watt::new(1.0);
let w2 = Watt::new(2.0);
assert_eq!(w1 + w2, Watt::new(3.0));
}
}