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
72
73
74
75
76
77
78
79
80
81
82
pub fn hello_world(planet: u8) -> Option<&'static str> {
return match planet {
0 => Some("Hello Sol!"),
1 => Some("Hello Mercury!"),
2 => Some("Hello Venus!"),
3 => Some("Hello Earth!"),
4 => Some("Hello Mars!"),
5 => Some("Hello Jupiter!"),
6 => Some("Hello Saturn!"),
7 => Some("Hello Uranus!"),
8 => Some("Hello Neptune!"),
_ => None
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn hello_sol() {
assert_eq!(hello_world(0), Some("Hello Sol!"));
}
#[test]
fn hello_mercury() {
assert_eq!(hello_world(1), Some("Hello Mercury!"));
}
#[test]
fn hello_venus() {
assert_eq!(hello_world(2), Some("Hello Venus!"));
}
#[test]
fn hello_earth() {
assert_eq!(hello_world(3), Some("Hello Earth!"));
}
#[test]
fn hello_mars() {
assert_eq!(hello_world(4), Some("Hello Mars!"));
}
#[test]
fn hello_jupiter() {
assert_eq!(hello_world(5), Some("Hello Jupiter!"));
}
#[test]
fn hello_saturn() {
assert_eq!(hello_world(6), Some("Hello Saturn!"));
}
#[test]
fn hello_uranus() {
assert_eq!(hello_world(7), Some("Hello Uranus!"));
}
#[test]
fn hello_neptune() {
assert_eq!(hello_world(8), Some("Hello Neptune!"));
}
#[test]
fn pluto_isnt_a_planet() {
assert_eq!(hello_world(9), None);
}
}