Skip to content

Commit a75ab3d

Browse files
committed
fix: apply fixes from pre-commit run --all
Some tests get manual formatting and local `clang-format off` to work around exercism/cpp-test-runner#73
1 parent d38c023 commit a75ab3d

File tree

388 files changed

+4230
-5187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

388 files changed

+4230
-5187
lines changed
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
// ERROR: FILE CORRUPTED. Please supply valid C++ Code.
22

3-
hp1,üapöhp2ö%Äcountöiöma1,öhp2ö%Älawöhp3öö/önextöstepö%Ädacöiöml1ö%Älawö7ö%Ädacöiömb1ö%Ärandomöö%Äscrö9sö%Äsirö9sö%Äxctöhr1ö%Äaddöiömx1ö%Ädacöiömx1ö%Äswapö%Äaddöiömy1ö%Ädacöiömy1ö%Ärandomö%Äscrö9sö%Äsirö9sö%Äxctöhr2ö%Ädacöiömdyö%Ädioöiömdxö%Äsetupö.hpt,3ö%Älacöranö%Ädacöiömth
3+
hp1, üapöhp2ö % Äcountöiöma1,
4+
öhp2ö % Älawöhp3öö / önextöstepö % Ädacöiöml1ö % Älawö7ö % Ädacöiömb1ö %
5+
Ärandomöö % Äscrö9sö % Äsirö9sö % Äxctöhr1ö % Äaddöiömx1ö %
6+
Ädacöiömx1ö % Äswapö % Äaddöiömy1ö % Ädacöiömy1ö % Ärandomö % Äscrö9sö %
7+
Äsirö9sö % Äxctöhr2ö % Ädacöiömdyö % Ädioöiömdxö % Äsetupö.hpt,
8+
3ö % Älacöranö % Ädacöiömth

exercises/concept/election-day/.meta/exemplar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void increment_vote_count(ElectionResult& result, int votes) {
3131
ElectionResult& determine_result(std::vector<ElectionResult>& count) {
3232
int winner_idx = 0;
3333
for (int i{}; i < count.size(); ++i) {
34-
if(count.at(i).votes > count.at(winner_idx).votes) {
34+
if (count.at(i).votes > count.at(winner_idx).votes) {
3535
winner_idx = i;
3636
}
3737
}

exercises/concept/election-day/election_day.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@ struct ElectionResult {
1616
// vote_count takes a reference to an `ElectionResult` as an argument and will
1717
// return the number of votes in the `ElectionResult.
1818

19-
2019
// TODO: Task 2
2120
// increment_vote_count takes a reference to an `ElectionResult` as an argument
2221
// and a number of votes (int), and will increment the `ElectionResult` by that
2322
// number of votes.
2423

25-
2624
// TODO: Task 3
2725
// determine_result receives the reference to a final_count and returns a
2826
// reference to the `ElectionResult` of the new president. It also changes the
2927
// name of the winner by prefixing it with "President". The final count is given
3028
// in the form of a `reference` to `std::vector<ElectionResult>`, a vector with
3129
// `ElectionResults` of all the participating candidates.
3230

33-
3431
} // namespace election

exercises/concept/election-day/election_day_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ TEST_CASE("Presidency, two candidates", "[task_3]") {
6363
REQUIRE(result.name == expected);
6464
}
6565

66-
6766
TEST_CASE("Presidency, several candidates", "[task_3]") {
6867
ElectionResult option1{"David", 11};
6968
ElectionResult option2{"Shaw", 12};

exercises/concept/ellens-alien-game/ellens_alien_game_test.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ TEST_CASE("Alien is always hit", "[task_2]") {
3232
REQUIRE(alien.hit());
3333
}
3434

35-
TEST_CASE("Alien is alive while health is greater than 0 and stays dead afterwards", "[task_3]") {
35+
TEST_CASE(
36+
"Alien is alive while health is greater than 0 and stays dead afterwards",
37+
"[task_3]") {
3638
Alien alien{2, 54};
3739
REQUIRE(alien.is_alive());
3840
alien.hit();

exercises/concept/freelancer-rates/freelancer_rates_test.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77

88
using namespace std;
99

10-
TEST_CASE("it's the hourly_rate times 8", "[task_1]") { REQUIRE(daily_rate(50) == 400.0); }
10+
TEST_CASE("it's the hourly_rate times 8", "[task_1]") {
11+
REQUIRE(daily_rate(50) == 400.0);
12+
}
1113

1214
#if defined(EXERCISM_RUN_ALL_TESTS)
1315

14-
TEST_CASE("it always returns a float", "[task_1]") { REQUIRE(daily_rate(60) == 480.0); }
16+
TEST_CASE("it always returns a float", "[task_1]") {
17+
REQUIRE(daily_rate(60) == 480.0);
18+
}
1519

16-
TEST_CASE("it does not round", "[task_1]") { REQUIRE(daily_rate(55.1) == 440.8); }
20+
TEST_CASE("it does not round", "[task_1]") {
21+
REQUIRE(daily_rate(55.1) == 440.8);
22+
}
1723

18-
TEST_CASE("a discount of 10 percent leaves 90 percent of the original price", "[task_2]") {
24+
TEST_CASE("a discount of 10 percent leaves 90 percent of the original price",
25+
"[task_2]") {
1926
REQUIRE(apply_discount(140.0, 10) == 126.0);
2027
}
2128

exercises/concept/interest-is-interesting/interest_is_interesting_test.cpp

+62-31
Original file line numberDiff line numberDiff line change
@@ -8,144 +8,173 @@
88
TEST_CASE("Minimal first interest rate", "[task_1]") {
99
double balance{0};
1010
double want{0.5};
11-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
11+
REQUIRE_THAT(interest_rate(balance),
12+
Catch::Matchers::WithinRel(want, 0.000001));
1213
}
1314

1415
#if defined(EXERCISM_RUN_ALL_TESTS)
1516

1617
TEST_CASE("Tiny first interest rate", "[task_1]") {
1718
double balance{0.000001};
1819
double want{0.5};
19-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
20+
REQUIRE_THAT(interest_rate(balance),
21+
Catch::Matchers::WithinRel(want, 0.000001));
2022
}
2123

2224
TEST_CASE("Maximum first interest rate", "[task_1]") {
2325
double balance{999.9999};
2426
double want{0.5};
25-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
27+
REQUIRE_THAT(interest_rate(balance),
28+
Catch::Matchers::WithinRel(want, 0.000001));
2629
}
2730

2831
TEST_CASE("Minimal second interest rate", "[task_1]") {
2932
double balance{1000.0};
3033
double want{1.621};
31-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
34+
REQUIRE_THAT(interest_rate(balance),
35+
Catch::Matchers::WithinRel(want, 0.000001));
3236
}
3337

3438
TEST_CASE("Tiny second interest rate", "[task_1]") {
3539
double balance{1000.0001};
3640
double want{1.621};
37-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
41+
REQUIRE_THAT(interest_rate(balance),
42+
Catch::Matchers::WithinRel(want, 0.000001));
3843
}
3944

4045
TEST_CASE("Maximum second interest rate", "[task_1]") {
4146
double balance{4999.9990};
4247
double want{1.621};
43-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
48+
REQUIRE_THAT(interest_rate(balance),
49+
Catch::Matchers::WithinRel(want, 0.000001));
4450
}
4551

4652
TEST_CASE("Minimal third interest rate", "[task_1]") {
4753
double balance{5000.0000};
4854
double want{2.475};
49-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
55+
REQUIRE_THAT(interest_rate(balance),
56+
Catch::Matchers::WithinRel(want, 0.000001));
5057
}
5158

5259
TEST_CASE("Tiny third interest rate", "[task_1]") {
5360
double balance{5000.0001};
5461
double want{2.475};
55-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
62+
REQUIRE_THAT(interest_rate(balance),
63+
Catch::Matchers::WithinRel(want, 0.000001));
5664
}
5765

5866
TEST_CASE("Large third interest rate", "[task_1]") {
5967
double balance{5639998.742909};
6068
double want{2.475};
61-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
69+
REQUIRE_THAT(interest_rate(balance),
70+
Catch::Matchers::WithinRel(want, 0.000001));
6271
}
6372

6473
TEST_CASE("Rate on minimal negative balance", "[task_1]") {
6574
double balance{-0.000001};
6675
double want{3.213};
67-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
76+
REQUIRE_THAT(interest_rate(balance),
77+
Catch::Matchers::WithinRel(want, 0.000001));
6878
}
6979

7080
TEST_CASE("Rate on small negative balance", "[task_1]") {
7181
double balance{-0.123};
7282
double want{3.213};
73-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
83+
REQUIRE_THAT(interest_rate(balance),
84+
Catch::Matchers::WithinRel(want, 0.000001));
7485
}
7586

7687
TEST_CASE("Rate on regular negative balance", "[task_1]") {
7788
double balance{-300.0};
7889
double want{3.213};
79-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
90+
REQUIRE_THAT(interest_rate(balance),
91+
Catch::Matchers::WithinRel(want, 0.000001));
8092
}
8193

8294
TEST_CASE("Rate on large negative balance", "[task_1]") {
8395
double balance{-152964.231};
8496
double want{3.213};
85-
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
97+
REQUIRE_THAT(interest_rate(balance),
98+
Catch::Matchers::WithinRel(want, 0.000001));
8699
}
87100

88101
TEST_CASE("Interest on negative balance", "[task_2]") {
89102
double balance{-10000.0};
90103
double want{-321.3};
91-
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
104+
REQUIRE_THAT(yearly_interest(balance),
105+
Catch::Matchers::WithinRel(want, 0.000001));
92106
}
93107
TEST_CASE("Interest on small balance", "[task_2]") {
94108
double balance{555.43};
95109
double want{2.77715};
96-
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
110+
REQUIRE_THAT(yearly_interest(balance),
111+
Catch::Matchers::WithinRel(want, 0.000001));
97112
}
98113
TEST_CASE("Interest on medium balance", "[task_2]") {
99114
double balance{4999.99};
100115
double want{81.0498379};
101-
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
116+
REQUIRE_THAT(yearly_interest(balance),
117+
Catch::Matchers::WithinRel(want, 0.000001));
102118
}
103119
TEST_CASE("Interest on large balance", "[task_2]") {
104120
double balance{34600.80};
105121
double want{856.3698};
106-
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
122+
REQUIRE_THAT(yearly_interest(balance),
123+
Catch::Matchers::WithinRel(want, 0.000001));
107124
}
108125

109126
TEST_CASE("Annual balance update for empty start balance", "[task_3]") {
110127
double balance{0.0};
111128
double want{0.0000};
112-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
129+
REQUIRE_THAT(annual_balance_update(balance),
130+
Catch::Matchers::WithinRel(want, 0.000001));
113131
}
114132

115-
TEST_CASE("Annual balance update for small positive start balance", "[task_3]") {
133+
TEST_CASE("Annual balance update for small positive start balance",
134+
"[task_3]") {
116135
double balance{0.000001};
117136
double want{0.000001005};
118-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
137+
REQUIRE_THAT(annual_balance_update(balance),
138+
Catch::Matchers::WithinRel(want, 0.000001));
119139
}
120140

121-
TEST_CASE("Annual balance update for average positive start balance", "[task_3]") {
141+
TEST_CASE("Annual balance update for average positive start balance",
142+
"[task_3]") {
122143
double balance{1000.0};
123144
double want{1016.210000};
124-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
145+
REQUIRE_THAT(annual_balance_update(balance),
146+
Catch::Matchers::WithinRel(want, 0.000001));
125147
}
126148

127-
TEST_CASE("Annual balance update for large positive start balance", "[task_3]") {
149+
TEST_CASE("Annual balance update for large positive start balance",
150+
"[task_3]") {
128151
double balance{1000.2001};
129152
double want{1016.413343621};
130-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
153+
REQUIRE_THAT(annual_balance_update(balance),
154+
Catch::Matchers::WithinRel(want, 0.000001));
131155
}
132156

133157
TEST_CASE("Annual balance update for huge positive start balance", "[task_3]") {
134158
double balance{898124017.826243404425};
135159
double want{920352587.2674429417};
136-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
160+
REQUIRE_THAT(annual_balance_update(balance),
161+
Catch::Matchers::WithinRel(want, 0.000001));
137162
}
138163

139-
TEST_CASE("Annual balance update for small negative start balance", "[task_3]") {
164+
TEST_CASE("Annual balance update for small negative start balance",
165+
"[task_3]") {
140166
double balance{-0.123};
141167
double want{-0.12695199};
142-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
168+
REQUIRE_THAT(annual_balance_update(balance),
169+
Catch::Matchers::WithinRel(want, 0.000001));
143170
}
144171

145-
TEST_CASE("Annual balance update for large negative start balance", "[task_3]") {
172+
TEST_CASE("Annual balance update for large negative start balance",
173+
"[task_3]") {
146174
double balance{-152964.231};
147175
double want{-157878.97174203};
148-
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
176+
REQUIRE_THAT(annual_balance_update(balance),
177+
Catch::Matchers::WithinRel(want, 0.000001));
149178
}
150179

151180
TEST_CASE("Years before desired balance for small start balance", "[task_4]") {
@@ -154,7 +183,8 @@ TEST_CASE("Years before desired balance for small start balance", "[task_4]") {
154183
int want{47};
155184
REQUIRE(years_until_desired_balance(balance, target_balance) == want);
156185
}
157-
TEST_CASE("Years before desired balance for average start balance", "[task_4]") {
186+
TEST_CASE("Years before desired balance for average start balance",
187+
"[task_4]") {
158188
double balance{1000.0};
159189
double target_balance{1100.0};
160190
int want{6};
@@ -166,7 +196,8 @@ TEST_CASE("Years before desired balance for large start balance", "[task_4]") {
166196
int want{5};
167197
REQUIRE(years_until_desired_balance(balance, target_balance) == want);
168198
}
169-
TEST_CASE("Years before large difference between start and target balance", "[task_4]") {
199+
TEST_CASE("Years before large difference between start and target balance",
200+
"[task_4]") {
170201
double balance{2345.67};
171202
double target_balance{12345.6789};
172203
int want{85};

exercises/concept/lasagna-master/.meta/exemplar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void addSecretIngredient(std::vector<std::string>& myList,
2929
}
3030

3131
std::vector<double> scaleRecipe(const std::vector<double>& quantities,
32-
int portions) {
32+
int portions) {
3333
std::vector<double> result(quantities);
3434
for (auto& quantity : result) {
3535
quantity *= portions / 2.0;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
#pragma once
22

3-
#include <vector>
43
#include <string>
4+
#include <vector>
55

66
namespace lasagna_master {
77

8-
struct amount { int noodles; double sauce; };
8+
struct amount {
9+
int noodles;
10+
double sauce;
11+
};
912

1013
int preparationTime(const std::vector<std::string>& layers, int prepTime = 2);
1114
amount quantities(const std::vector<std::string>& layers);
12-
void addSecretIngredient(std::vector<std::string>& myList, const std::vector<std::string>& friendsList);
13-
void addSecretIngredient(std::vector<std::string>& myList, const std::string& secretIngredient);
14-
std::vector<double> scaleRecipe(const std::vector<double>& quantities, int portions);
15+
void addSecretIngredient(std::vector<std::string>& myList,
16+
const std::vector<std::string>& friendsList);
17+
void addSecretIngredient(std::vector<std::string>& myList,
18+
const std::string& secretIngredient);
19+
std::vector<double> scaleRecipe(const std::vector<double>& quantities,
20+
int portions);
1521

1622
} // namespace lasagna_master
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
#include "lasagna_master.h"
22

3-
namespace lasagna_master {
4-
5-
6-
} // namespace lasagna_master
3+
namespace lasagna_master {} // namespace lasagna_master

0 commit comments

Comments
 (0)