|
5 | 5 | #include "test/catch.hpp"
|
6 | 6 | #endif
|
7 | 7 |
|
8 |
| -TEST_CASE("_1_yields_empty") |
9 |
| -{ |
10 |
| - const std::vector<int> expected{}; |
| 8 | +TEST_CASE("no factors", "[factors][924fc966-a8f5-4288-82f2-6b9224819ccd]") { |
| 9 | + const std::vector<long long> expected{}; |
11 | 10 |
|
12 |
| - const std::vector<int> actual{prime_factors::of(1)}; |
| 11 | + const std::vector<long long> actual{prime_factors::of(1)}; |
13 | 12 |
|
14 | 13 | REQUIRE(expected == actual);
|
15 | 14 | }
|
16 | 15 |
|
17 | 16 | #if defined(EXERCISM_RUN_ALL_TESTS)
|
18 |
| -TEST_CASE("_2_yields_2") |
19 |
| -{ |
20 |
| - const std::vector<int> expected{2}; |
| 17 | +TEST_CASE("prime number", "[factors][17e30670-b105-4305-af53-ddde182cb6ad]") { |
| 18 | + const std::vector<long long> expected{2}; |
21 | 19 |
|
22 |
| - const std::vector<int> actual{prime_factors::of(2)}; |
| 20 | + const std::vector<long long> actual{prime_factors::of(2)}; |
23 | 21 |
|
24 | 22 | REQUIRE(expected == actual);
|
25 | 23 | }
|
26 | 24 |
|
27 |
| -TEST_CASE("_3_yields_3") |
28 |
| -{ |
29 |
| - const std::vector<int> expected{3}; |
| 25 | +TEST_CASE("another prime number", |
| 26 | + "[factors][238d57c8-4c12-42ef-af34-ae4929f94789]") { |
| 27 | + const std::vector<long long> expected{3}; |
30 | 28 |
|
31 |
| - const std::vector<int> actual{prime_factors::of(3)}; |
| 29 | + const std::vector<long long> actual{prime_factors::of(3)}; |
32 | 30 |
|
33 | 31 | REQUIRE(expected == actual);
|
34 | 32 | }
|
35 | 33 |
|
36 |
| -TEST_CASE("_4_yields_2_2") |
37 |
| -{ |
38 |
| - const std::vector<int> expected{2, 2}; |
| 34 | +TEST_CASE("square of a prime", |
| 35 | + "[factors][f59b8350-a180-495a-8fb1-1712fbee1158]") { |
| 36 | + const std::vector<long long> expected{3, 3}; |
39 | 37 |
|
40 |
| - const std::vector<int> actual{prime_factors::of(4)}; |
| 38 | + const std::vector<long long> actual{prime_factors::of(9)}; |
41 | 39 |
|
42 | 40 | REQUIRE(expected == actual);
|
43 | 41 | }
|
44 | 42 |
|
45 |
| -TEST_CASE("_6_yields_2_3") |
46 |
| -{ |
47 |
| - const std::vector<int> expected{2, 3}; |
| 43 | +TEST_CASE("product of first prime", |
| 44 | + "[factors][756949d3-3158-4e3d-91f2-c4f9f043ee70]") { |
| 45 | + const std::vector<long long> expected{2, 2}; |
48 | 46 |
|
49 |
| - const std::vector<int> actual{prime_factors::of(6)}; |
| 47 | + const std::vector<long long> actual{prime_factors::of(4)}; |
50 | 48 |
|
51 | 49 | REQUIRE(expected == actual);
|
52 | 50 | }
|
53 | 51 |
|
54 |
| -TEST_CASE("_8_yields_2_2_2") |
55 |
| -{ |
56 |
| - const std::vector<int> expected{2, 2, 2}; |
| 52 | +TEST_CASE("cube of a prime", |
| 53 | + "[factors][bc8c113f-9580-4516-8669-c5fc29512ceb]") { |
| 54 | + const std::vector<long long> expected{2, 2, 2}; |
57 | 55 |
|
58 |
| - const std::vector<int> actual{prime_factors::of(8)}; |
| 56 | + const std::vector<long long> actual{prime_factors::of(8)}; |
59 | 57 |
|
60 | 58 | REQUIRE(expected == actual);
|
61 | 59 | }
|
62 | 60 |
|
63 |
| -TEST_CASE("_9_yields_3_3") |
64 |
| -{ |
65 |
| - const std::vector<int> expected{3, 3}; |
| 61 | +TEST_CASE("product of second prime", |
| 62 | + "[factors][7d6a3300-a4cb-4065-bd33-0ced1de6cb44]") { |
| 63 | + const std::vector<long long> expected{3, 3, 3}; |
66 | 64 |
|
67 |
| - const std::vector<int> actual{prime_factors::of(9)}; |
| 65 | + const std::vector<long long> actual{prime_factors::of(27)}; |
68 | 66 |
|
69 | 67 | REQUIRE(expected == actual);
|
70 | 68 | }
|
71 | 69 |
|
72 |
| -TEST_CASE("_27_yields_3_3_3") |
73 |
| -{ |
74 |
| - const std::vector<int> expected{3, 3, 3}; |
| 70 | +TEST_CASE("product of third prime", |
| 71 | + "[factors][073ac0b2-c915-4362-929d-fc45f7b9a9e4]") { |
| 72 | + const std::vector<long long> expected{5, 5, 5, 5}; |
75 | 73 |
|
76 |
| - const std::vector<int> actual{prime_factors::of(27)}; |
| 74 | + const std::vector<long long> actual{prime_factors::of(625)}; |
77 | 75 |
|
78 | 76 | REQUIRE(expected == actual);
|
79 | 77 | }
|
80 | 78 |
|
81 |
| -TEST_CASE("_625_yields_5_5_5_5") |
82 |
| -{ |
83 |
| - const std::vector<int> expected{5, 5, 5, 5}; |
| 79 | +TEST_CASE("product of first and second prime", |
| 80 | + "[factors][6e0e4912-7fb6-47f3-a9ad-dbcd79340c75]") { |
| 81 | + const std::vector<long long> expected{2, 3}; |
84 | 82 |
|
85 |
| - const std::vector<int> actual{prime_factors::of(625)}; |
| 83 | + const std::vector<long long> actual{prime_factors::of(6)}; |
86 | 84 |
|
87 | 85 | REQUIRE(expected == actual);
|
88 | 86 | }
|
89 | 87 |
|
90 |
| -TEST_CASE("_901255_yields_5_17_23_461") |
91 |
| -{ |
92 |
| - const std::vector<int> expected{5, 17, 23, 461}; |
| 88 | +TEST_CASE("product of primes and non-primes", |
| 89 | + "[factors][00485cd3-a3fe-4fbe-a64a-a4308fc1f870]") { |
| 90 | + const std::vector<long long> expected{2, 2, 3}; |
93 | 91 |
|
94 |
| - const std::vector<int> actual{prime_factors::of(901255)}; |
| 92 | + const std::vector<long long> actual{prime_factors::of(12)}; |
95 | 93 |
|
96 | 94 | REQUIRE(expected == actual);
|
97 | 95 | }
|
| 96 | + |
| 97 | +TEST_CASE("product of primes", |
| 98 | + "[factors][02251d54-3ca1-4a9b-85e1-b38f4b0ccb91]") { |
| 99 | + const std::vector<long long> expected{5, 17, 23, 461}; |
| 100 | + |
| 101 | + const std::vector<long long> actual{prime_factors::of(901255)}; |
| 102 | + |
| 103 | + REQUIRE(expected == actual); |
| 104 | +} |
| 105 | + |
| 106 | +TEST_CASE("factors include a large prime", |
| 107 | + "[factors][070cf8dc-e202-4285-aa37-8d775c9cd473]") { |
| 108 | + const std::vector<long long> expected{11, 9539, 894119}; |
| 109 | + |
| 110 | + const std::vector<long long> actual{prime_factors::of(93819012551)}; |
| 111 | + |
| 112 | + REQUIRE(expected == actual); |
| 113 | +} |
| 114 | + |
98 | 115 | #endif
|
0 commit comments