From f6f24dd665d9c3ac3d383731bcc308ff918de095 Mon Sep 17 00:00:00 2001 From: vaeng <34183939+vaeng@users.noreply.github.com> Date: Tue, 28 Jan 2025 16:14:31 +0100 Subject: [PATCH] format: reformat for clang conformity --- .../making-the-grade/.meta/exemplar.cpp | 40 ++++++++++--------- .../making-the-grade/making_the_grade.cpp | 10 +++-- .../making_the_grade_test.cpp | 17 +++++--- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/exercises/concept/making-the-grade/.meta/exemplar.cpp b/exercises/concept/making-the-grade/.meta/exemplar.cpp index c8a2956c..797dc957 100644 --- a/exercises/concept/making-the-grade/.meta/exemplar.cpp +++ b/exercises/concept/making-the-grade/.meta/exemplar.cpp @@ -5,18 +5,16 @@ // Round down all provided student scores. std::vector round_down_scores(std::vector student_scores) { std::vector rounded{}; - for(int i{}; i < student_scores.size(); ++i) + for (int i{}; i < student_scores.size(); ++i) rounded.emplace_back(student_scores.at(i)); return rounded; } - // Count the number of failing students out of the group provided. int count_failed_students(std::vector student_scores) { int counter{}; - for(int i{}; i < student_scores.size(); ++i) { - if (student_scores.at(i) < 41) - ++counter; + for (int i{}; i < student_scores.size(); ++i) { + if (student_scores.at(i) < 41) ++counter; } return counter; } @@ -24,30 +22,34 @@ int count_failed_students(std::vector student_scores) { // Create a list of grade thresholds based on the provided highest grade. std::array letter_grades(int highest_score) { std::array grades{}; - for(int i{}, lower_threshold{41}, step_size{(highest_score - 40) / 4}; - i < 4; ++i) { + for (int i{}, lower_threshold{41}, step_size{(highest_score - 40) / 4}; + i < 4; ++i) { grades.at(i) = lower_threshold + step_size * i; } return grades; } // Organize the student's rank, name, and grade information in ascending order. -std::vector student_ranking(std::vector student_scores, std::vector student_names) { +std::vector student_ranking( + std::vector student_scores, std::vector student_names) { std::vector ranking{}; - for(int i{}; i < student_scores.size(); ++i) { - ranking.emplace_back(std::to_string(i + 1) + ". " + student_names.at(i) + ": " + std::to_string(student_scores.at(i))); - } - + for (int i{}; i < student_scores.size(); ++i) { + ranking.emplace_back(std::to_string(i + 1) + ". " + + student_names.at(i) + ": " + + std::to_string(student_scores.at(i))); + } + return ranking; } -// Create a string that contains the name of the first student to make a perfect score on the exam. -std::string perfect_score(std::vector student_scores, std::vector student_names) { +// Create a string that contains the name of the first student to make a perfect +// score on the exam. +std::string perfect_score(std::vector student_scores, + std::vector student_names) { std::vector ranking{}; - for(int i{}; i < student_scores.size(); ++i) { - if (student_scores.at(i) == 100) - return student_names.at(i); - } - + for (int i{}; i < student_scores.size(); ++i) { + if (student_scores.at(i) == 100) return student_names.at(i); + } + return ""; } \ No newline at end of file diff --git a/exercises/concept/making-the-grade/making_the_grade.cpp b/exercises/concept/making-the-grade/making_the_grade.cpp index 4e84ca34..3ef90da9 100644 --- a/exercises/concept/making-the-grade/making_the_grade.cpp +++ b/exercises/concept/making-the-grade/making_the_grade.cpp @@ -8,7 +8,6 @@ std::vector round_down_scores(std::vector student_scores) { return {}; } - // Count the number of failing students out of the group provided. int count_failed_students(std::vector student_scores) { // TODO: Implement count_failed_students @@ -22,13 +21,16 @@ std::array letter_grades(int highest_score) { } // Organize the student's rank, name, and grade information in ascending order. -std::vector student_ranking(std::vector student_scores, std::vector student_names) { +std::vector student_ranking( + std::vector student_scores, std::vector student_names) { // TODO: Implement student_ranking return {}; } -// Create a string that contains the name of the first student to make a perfect score on the exam. -std::string perfect_score(std::vector student_scores, std::vector student_names) { +// Create a string that contains the name of the first student to make a perfect +// score on the exam. +std::string perfect_score(std::vector student_scores, + std::vector student_names) { // TODO: Implement perfect_score return ""; } diff --git a/exercises/concept/making-the-grade/making_the_grade_test.cpp b/exercises/concept/making-the-grade/making_the_grade_test.cpp index f03a7595..e66b7a58 100644 --- a/exercises/concept/making-the-grade/making_the_grade_test.cpp +++ b/exercises/concept/making-the-grade/making_the_grade_test.cpp @@ -82,9 +82,11 @@ TEST_CASE("Rank one student", "[task_4]") { TEST_CASE("Rank several student", "[task_4]") { vector grades{100, 98, 92, 86, 70, 68, 67, 60}; - vector names{"Rui", "Betty", "Joci", "Yoshi", "Kora", "Bern", "Jan", "Rose"}; - vector expected{"1. Rui: 100", "2. Betty: 98", "3. Joci: 92", "4. Yoshi: 86", - "5. Kora: 70", "6. Bern: 68", "7. Jan: 67", "8. Rose: 60"}; + vector names{"Rui", "Betty", "Joci", "Yoshi", + "Kora", "Bern", "Jan", "Rose"}; + vector expected{"1. Rui: 100", "2. Betty: 98", "3. Joci: 92", + "4. Yoshi: 86", "5. Kora: 70", "6. Bern: 68", + "7. Jan: 67", "8. Rose: 60"}; vector actual = student_ranking(grades, names); REQUIRE(expected == actual); @@ -92,7 +94,8 @@ TEST_CASE("Rank several student", "[task_4]") { TEST_CASE("No perfect score", "[task_5]") { vector grades{11, 34, 92, 23, 70, 76, 67, 60}; - vector names{"Rui", "Betty", "Joci", "Yoshi", "Kora", "Bern", "Jan", "Rose"}; + vector names{"Rui", "Betty", "Joci", "Yoshi", + "Kora", "Bern", "Jan", "Rose"}; string expected{""}; string actual = perfect_score(grades, names); @@ -101,7 +104,8 @@ TEST_CASE("No perfect score", "[task_5]") { TEST_CASE("One perfect score", "[task_5]") { vector grades{11, 34, 92, 23, 70, 76, 67, 100}; - vector names{"Rui", "Betty", "Joci", "Yoshi", "Kora", "Bern", "Jan", "Rose"}; + vector names{"Rui", "Betty", "Joci", "Yoshi", + "Kora", "Bern", "Jan", "Rose"}; string expected{"Rose"}; string actual = perfect_score(grades, names); @@ -110,7 +114,8 @@ TEST_CASE("One perfect score", "[task_5]") { TEST_CASE("Several perfect scores", "[task_5]") { vector grades{11, 100, 92, 23, 70, 100, 67, 100}; - vector names{"Rui", "Betty", "Joci", "Yoshi", "Kora", "Bern", "Jan", "Rose"}; + vector names{"Rui", "Betty", "Joci", "Yoshi", + "Kora", "Bern", "Jan", "Rose"}; string expected{"Betty"}; string actual = perfect_score(grades, names);