-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathtest_armstrong_numbers.zig
More file actions
98 lines (71 loc) · 2.75 KB
/
Copy pathtest_armstrong_numbers.zig
File metadata and controls
98 lines (71 loc) · 2.75 KB
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
const std = @import("std");
const testing = std.testing;
const isArmstrongNumber = @import("armstrong_numbers.zig").isArmstrongNumber;
// Adding "return error.SkipZigTest" to the top of each test results in a compiler error
// This wrapper function around error.SkipZigTest appeases the compiler
fn skipTest() !void {
return error.SkipZigTest;
}
test "zero is an armstrong number" {
try testing.expect(isArmstrongNumber(0));
}
test "single-digit numbers are armstrong numbers" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(isArmstrongNumber(5));
}
test "there are no two-digit armstrong numbers" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(!isArmstrongNumber(10));
}
test "three-digit number that is an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(isArmstrongNumber(153));
}
test "three-digit number that is not an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(!isArmstrongNumber(100));
}
test "four-digit number that is an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(isArmstrongNumber(9_474));
}
test "four-digit number that is not an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(!isArmstrongNumber(9_475));
}
test "seven-digit number that is an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(isArmstrongNumber(9_926_315));
}
test "seven-digit number that is not an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(!isArmstrongNumber(9_926_314));
}
test "33-digit number that is an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(isArmstrongNumber(186_709_961_001_538_790_100_634_132_976_990));
}
test "38-digit number that is not an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(!isArmstrongNumber(99_999_999_999_999_999_999_999_999_999_999_999_999));
}
test "the largest and last armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(isArmstrongNumber(115_132_219_018_763_992_565_095_597_973_971_522_401));
}
test "the largest 128-bit unsigned integer value is not an armstrong number" {
// Delete or comment out below line to run test
try skipTest();
try testing.expect(!isArmstrongNumber(340_282_366_920_938_463_463_374_607_431_768_211_455));
}