-
Notifications
You must be signed in to change notification settings - Fork 520
/
perfect-numbers.rs
107 lines (95 loc) · 2.53 KB
/
perfect-numbers.rs
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use perfect_numbers::*;
#[test]
fn smallest_perfect_number_is_classified_correctly() {
let input = 6;
let output = classify(input);
let expected = Some(Classification::Perfect);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn medium_perfect_number_is_classified_correctly() {
let input = 28;
let output = classify(input);
let expected = Some(Classification::Perfect);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn large_perfect_number_is_classified_correctly() {
let input = 33_550_336;
let output = classify(input);
let expected = Some(Classification::Perfect);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn smallest_abundant_number_is_classified_correctly() {
let input = 12;
let output = classify(input);
let expected = Some(Classification::Abundant);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn medium_abundant_number_is_classified_correctly() {
let input = 30;
let output = classify(input);
let expected = Some(Classification::Abundant);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn large_abundant_number_is_classified_correctly() {
let input = 33_550_335;
let output = classify(input);
let expected = Some(Classification::Abundant);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn smallest_prime_deficient_number_is_classified_correctly() {
let input = 2;
let output = classify(input);
let expected = Some(Classification::Deficient);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn smallest_non_prime_deficient_number_is_classified_correctly() {
let input = 4;
let output = classify(input);
let expected = Some(Classification::Deficient);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn medium_deficient_number_is_classified_correctly() {
let input = 32;
let output = classify(input);
let expected = Some(Classification::Deficient);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn large_deficient_number_is_classified_correctly() {
let input = 33_550_337;
let output = classify(input);
let expected = Some(Classification::Deficient);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn edge_case_no_factors_other_than_itself_is_classified_correctly() {
let input = 1;
let output = classify(input);
let expected = Some(Classification::Deficient);
assert_eq!(output, expected);
}
#[test]
#[ignore]
fn zero_is_rejected_as_it_is_not_a_positive_integer() {
let input = 0;
let output = classify(input);
assert!(output.is_none());
}