Skip to content

Commit

Permalink
fix: apply fixes from pre-commit run --all
Browse files Browse the repository at this point in the history
Some tests get manual formatting and local `clang-format off` to work around
exercism/cpp-test-runner#73
  • Loading branch information
ahans committed Apr 9, 2024
1 parent d38c023 commit a75ab3d
Show file tree
Hide file tree
Showing 388 changed files with 4,230 additions and 5,187 deletions.
7 changes: 6 additions & 1 deletion exercises/concept/doctor-data/doctor_data.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// ERROR: FILE CORRUPTED. Please supply valid C++ Code.

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
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
2 changes: 1 addition & 1 deletion exercises/concept/election-day/.meta/exemplar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void increment_vote_count(ElectionResult& result, int votes) {
ElectionResult& determine_result(std::vector<ElectionResult>& count) {
int winner_idx = 0;
for (int i{}; i < count.size(); ++i) {
if(count.at(i).votes > count.at(winner_idx).votes) {
if (count.at(i).votes > count.at(winner_idx).votes) {
winner_idx = i;
}
}
Expand Down
3 changes: 0 additions & 3 deletions exercises/concept/election-day/election_day.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ struct ElectionResult {
// vote_count takes a reference to an `ElectionResult` as an argument and will
// return the number of votes in the `ElectionResult.


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


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


} // namespace election
1 change: 0 additions & 1 deletion exercises/concept/election-day/election_day_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ TEST_CASE("Presidency, two candidates", "[task_3]") {
REQUIRE(result.name == expected);
}


TEST_CASE("Presidency, several candidates", "[task_3]") {
ElectionResult option1{"David", 11};
ElectionResult option2{"Shaw", 12};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ TEST_CASE("Alien is always hit", "[task_2]") {
REQUIRE(alien.hit());
}

TEST_CASE("Alien is alive while health is greater than 0 and stays dead afterwards", "[task_3]") {
TEST_CASE(
"Alien is alive while health is greater than 0 and stays dead afterwards",
"[task_3]") {
Alien alien{2, 54};
REQUIRE(alien.is_alive());
alien.hit();
Expand Down
15 changes: 11 additions & 4 deletions exercises/concept/freelancer-rates/freelancer_rates_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@

using namespace std;

TEST_CASE("it's the hourly_rate times 8", "[task_1]") { REQUIRE(daily_rate(50) == 400.0); }
TEST_CASE("it's the hourly_rate times 8", "[task_1]") {
REQUIRE(daily_rate(50) == 400.0);
}

#if defined(EXERCISM_RUN_ALL_TESTS)

TEST_CASE("it always returns a float", "[task_1]") { REQUIRE(daily_rate(60) == 480.0); }
TEST_CASE("it always returns a float", "[task_1]") {
REQUIRE(daily_rate(60) == 480.0);
}

TEST_CASE("it does not round", "[task_1]") { REQUIRE(daily_rate(55.1) == 440.8); }
TEST_CASE("it does not round", "[task_1]") {
REQUIRE(daily_rate(55.1) == 440.8);
}

TEST_CASE("a discount of 10 percent leaves 90 percent of the original price", "[task_2]") {
TEST_CASE("a discount of 10 percent leaves 90 percent of the original price",
"[task_2]") {
REQUIRE(apply_discount(140.0, 10) == 126.0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,144 +8,173 @@
TEST_CASE("Minimal first interest rate", "[task_1]") {
double balance{0};
double want{0.5};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

#if defined(EXERCISM_RUN_ALL_TESTS)

TEST_CASE("Tiny first interest rate", "[task_1]") {
double balance{0.000001};
double want{0.5};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Maximum first interest rate", "[task_1]") {
double balance{999.9999};
double want{0.5};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Minimal second interest rate", "[task_1]") {
double balance{1000.0};
double want{1.621};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Tiny second interest rate", "[task_1]") {
double balance{1000.0001};
double want{1.621};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Maximum second interest rate", "[task_1]") {
double balance{4999.9990};
double want{1.621};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Minimal third interest rate", "[task_1]") {
double balance{5000.0000};
double want{2.475};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Tiny third interest rate", "[task_1]") {
double balance{5000.0001};
double want{2.475};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Large third interest rate", "[task_1]") {
double balance{5639998.742909};
double want{2.475};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Rate on minimal negative balance", "[task_1]") {
double balance{-0.000001};
double want{3.213};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Rate on small negative balance", "[task_1]") {
double balance{-0.123};
double want{3.213};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Rate on regular negative balance", "[task_1]") {
double balance{-300.0};
double want{3.213};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Rate on large negative balance", "[task_1]") {
double balance{-152964.231};
double want{3.213};
REQUIRE_THAT(interest_rate(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(interest_rate(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Interest on negative balance", "[task_2]") {
double balance{-10000.0};
double want{-321.3};
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(yearly_interest(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}
TEST_CASE("Interest on small balance", "[task_2]") {
double balance{555.43};
double want{2.77715};
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(yearly_interest(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}
TEST_CASE("Interest on medium balance", "[task_2]") {
double balance{4999.99};
double want{81.0498379};
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(yearly_interest(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}
TEST_CASE("Interest on large balance", "[task_2]") {
double balance{34600.80};
double want{856.3698};
REQUIRE_THAT(yearly_interest(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(yearly_interest(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for empty start balance", "[task_3]") {
double balance{0.0};
double want{0.0000};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for small positive start balance", "[task_3]") {
TEST_CASE("Annual balance update for small positive start balance",
"[task_3]") {
double balance{0.000001};
double want{0.000001005};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for average positive start balance", "[task_3]") {
TEST_CASE("Annual balance update for average positive start balance",
"[task_3]") {
double balance{1000.0};
double want{1016.210000};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for large positive start balance", "[task_3]") {
TEST_CASE("Annual balance update for large positive start balance",
"[task_3]") {
double balance{1000.2001};
double want{1016.413343621};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for huge positive start balance", "[task_3]") {
double balance{898124017.826243404425};
double want{920352587.2674429417};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for small negative start balance", "[task_3]") {
TEST_CASE("Annual balance update for small negative start balance",
"[task_3]") {
double balance{-0.123};
double want{-0.12695199};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Annual balance update for large negative start balance", "[task_3]") {
TEST_CASE("Annual balance update for large negative start balance",
"[task_3]") {
double balance{-152964.231};
double want{-157878.97174203};
REQUIRE_THAT(annual_balance_update(balance), Catch::Matchers::WithinRel(want, 0.000001));
REQUIRE_THAT(annual_balance_update(balance),
Catch::Matchers::WithinRel(want, 0.000001));
}

TEST_CASE("Years before desired balance for small start balance", "[task_4]") {
Expand All @@ -154,7 +183,8 @@ TEST_CASE("Years before desired balance for small start balance", "[task_4]") {
int want{47};
REQUIRE(years_until_desired_balance(balance, target_balance) == want);
}
TEST_CASE("Years before desired balance for average start balance", "[task_4]") {
TEST_CASE("Years before desired balance for average start balance",
"[task_4]") {
double balance{1000.0};
double target_balance{1100.0};
int want{6};
Expand All @@ -166,7 +196,8 @@ TEST_CASE("Years before desired balance for large start balance", "[task_4]") {
int want{5};
REQUIRE(years_until_desired_balance(balance, target_balance) == want);
}
TEST_CASE("Years before large difference between start and target balance", "[task_4]") {
TEST_CASE("Years before large difference between start and target balance",
"[task_4]") {
double balance{2345.67};
double target_balance{12345.6789};
int want{85};
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/lasagna-master/.meta/exemplar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void addSecretIngredient(std::vector<std::string>& myList,
}

std::vector<double> scaleRecipe(const std::vector<double>& quantities,
int portions) {
int portions) {
std::vector<double> result(quantities);
for (auto& quantity : result) {
quantity *= portions / 2.0;
Expand Down
16 changes: 11 additions & 5 deletions exercises/concept/lasagna-master/.meta/exemplar.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#pragma once

#include <vector>
#include <string>
#include <vector>

namespace lasagna_master {

struct amount { int noodles; double sauce; };
struct amount {
int noodles;
double sauce;
};

int preparationTime(const std::vector<std::string>& layers, int prepTime = 2);
amount quantities(const std::vector<std::string>& layers);
void addSecretIngredient(std::vector<std::string>& myList, const std::vector<std::string>& friendsList);
void addSecretIngredient(std::vector<std::string>& myList, const std::string& secretIngredient);
std::vector<double> scaleRecipe(const std::vector<double>& quantities, int portions);
void addSecretIngredient(std::vector<std::string>& myList,
const std::vector<std::string>& friendsList);
void addSecretIngredient(std::vector<std::string>& myList,
const std::string& secretIngredient);
std::vector<double> scaleRecipe(const std::vector<double>& quantities,
int portions);

} // namespace lasagna_master
5 changes: 1 addition & 4 deletions exercises/concept/lasagna-master/lasagna_master.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include "lasagna_master.h"

namespace lasagna_master {


} // namespace lasagna_master
namespace lasagna_master {} // namespace lasagna_master
Loading

0 comments on commit a75ab3d

Please sign in to comment.