diff --git a/bin/check-exercises.sh b/bin/check-exercises.sh index a89cdacd..be3b167d 100755 --- a/bin/check-exercises.sh +++ b/bin/check-exercises.sh @@ -21,7 +21,7 @@ elif git diff --name-only master | grep "^CMakeLists.txt"; then cmake --build "$repo" -- test_hello-world cmake --build "$repo" else - tests="$(git diff --name-only master | grep "^exercises/" | cut -d '/' -f2 | sed 's/.*/test_&/' | uniq | tr '\n' ' ')" + tests="$(git diff --diff-filter=d --name-only master | grep "^exercises/" | cut -d '/' -f2 | sed 's/.*/test_&/' | uniq | tr '\n' ' ')" if [ ${#tests} -ne 0 ]; then echo "Running only tests that have changed." cmake --build "$repo" -- $tests diff --git a/config.json b/config.json index 100ca81e..eab2d6e1 100644 --- a/config.json +++ b/config.json @@ -475,7 +475,7 @@ ] }, { - "slug": "bracket-push", + "slug": "matching-brackets", "uuid": "4a517292-3472-40f2-b4b8-5c8c25219ea5", "core": false, "unlocked_by": "pangram", diff --git a/exercises/bracket-push/bracket_push_test.cpp b/exercises/bracket-push/bracket_push_test.cpp deleted file mode 100644 index f9265abb..00000000 --- a/exercises/bracket-push/bracket_push_test.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "bracket_push.h" -#include "test/catch.hpp" - -TEST_CASE("paired_square_brackets") -{ - REQUIRE(bracket_push::check("[]")); -} - -#if defined(EXERCISM_RUN_ALL_TESTS) -TEST_CASE("empty_string") -{ - REQUIRE(bracket_push::check("")); -} - -TEST_CASE("unpaired_brackets") -{ - REQUIRE(!bracket_push::check("[[")); -} - -TEST_CASE("wrong_ordered_brackets") -{ - REQUIRE(!bracket_push::check("}{")); -} - -TEST_CASE("wrong_closing_bracket") -{ - REQUIRE(!bracket_push::check("{]")); -} - -TEST_CASE("paired_with_whitespace") -{ - REQUIRE(bracket_push::check("{ }")); -} - -TEST_CASE("simple_nested_brackets") -{ - REQUIRE(bracket_push::check("{[]}")); -} - -TEST_CASE("several_paired_brackets") -{ - REQUIRE(bracket_push::check("{}[]")); -} - -TEST_CASE("paired_nested_brackets") -{ - REQUIRE(bracket_push::check("([{}({}[])])")); -} - -TEST_CASE("unopened_closing_brackets") -{ - REQUIRE(!bracket_push::check("{[)][]}")); -} - -TEST_CASE("unpaired_nested_brackets") -{ - REQUIRE(!bracket_push::check("([{])")); -} - -TEST_CASE("paired_wrong_nested_brackets") -{ - REQUIRE(!bracket_push::check("[({]})")); -} - -TEST_CASE("math_expression") -{ - REQUIRE(bracket_push::check("(((185 + 223.85) * 15) - 543)/2")); -} - -TEST_CASE("complex_latex_expression") -{ - REQUIRE(bracket_push::check("\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)")); -} -#endif diff --git a/exercises/bracket-push/example.h b/exercises/bracket-push/example.h deleted file mode 100644 index df281a8b..00000000 --- a/exercises/bracket-push/example.h +++ /dev/null @@ -1,13 +0,0 @@ -#if !defined(BRACKET_PUSH_H) -#define BRACKET_PUSH_H - -#include - -namespace bracket_push -{ - -bool check(std::string const& expression); - -} - -#endif diff --git a/exercises/bracket-push/CMakeLists.txt b/exercises/matching-brackets/CMakeLists.txt similarity index 100% rename from exercises/bracket-push/CMakeLists.txt rename to exercises/matching-brackets/CMakeLists.txt diff --git a/exercises/bracket-push/README.md b/exercises/matching-brackets/README.md similarity index 98% rename from exercises/bracket-push/README.md rename to exercises/matching-brackets/README.md index 7a89d1e4..be4cf796 100644 --- a/exercises/bracket-push/README.md +++ b/exercises/matching-brackets/README.md @@ -1,4 +1,4 @@ -# Bracket Push +# Matching Brackets Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched diff --git a/exercises/bracket-push/example.cpp b/exercises/matching-brackets/example.cpp similarity index 89% rename from exercises/bracket-push/example.cpp rename to exercises/matching-brackets/example.cpp index 7c666840..fe5c0c9a 100644 --- a/exercises/bracket-push/example.cpp +++ b/exercises/matching-brackets/example.cpp @@ -1,9 +1,9 @@ -#include "bracket_push.h" +#include "matching_brackets.h" #include using namespace std; -namespace bracket_push { +namespace matching_brackets { bool check(string const& expression) { diff --git a/exercises/matching-brackets/example.h b/exercises/matching-brackets/example.h new file mode 100644 index 00000000..7d0d7c4a --- /dev/null +++ b/exercises/matching-brackets/example.h @@ -0,0 +1,13 @@ +#if !defined(MATCHING_BRACKETS_H) +#define MATCHING_BRACKETS_H + +#include + +namespace matching_brackets +{ + +bool check(std::string const& expression); + +} + +#endif diff --git a/exercises/matching-brackets/matching_brackets_test.cpp b/exercises/matching-brackets/matching_brackets_test.cpp new file mode 100644 index 00000000..0c3c2c99 --- /dev/null +++ b/exercises/matching-brackets/matching_brackets_test.cpp @@ -0,0 +1,74 @@ +#include "matching_brackets.h" +#include "test/catch.hpp" + +TEST_CASE("paired_square_brackets") +{ + REQUIRE(matching_brackets::check("[]")); +} + +#if defined(EXERCISM_RUN_ALL_TESTS) +TEST_CASE("empty_string") +{ + REQUIRE(matching_brackets::check("")); +} + +TEST_CASE("unpaired_brackets") +{ + REQUIRE(!matching_brackets::check("[[")); +} + +TEST_CASE("wrong_ordered_brackets") +{ + REQUIRE(!matching_brackets::check("}{")); +} + +TEST_CASE("wrong_closing_bracket") +{ + REQUIRE(!matching_brackets::check("{]")); +} + +TEST_CASE("paired_with_whitespace") +{ + REQUIRE(matching_brackets::check("{ }")); +} + +TEST_CASE("simple_nested_brackets") +{ + REQUIRE(matching_brackets::check("{[]}")); +} + +TEST_CASE("several_paired_brackets") +{ + REQUIRE(matching_brackets::check("{}[]")); +} + +TEST_CASE("paired_nested_brackets") +{ + REQUIRE(matching_brackets::check("([{}({}[])])")); +} + +TEST_CASE("unopened_closing_brackets") +{ + REQUIRE(!matching_brackets::check("{[)][]}")); +} + +TEST_CASE("unpaired_nested_brackets") +{ + REQUIRE(!matching_brackets::check("([{])")); +} + +TEST_CASE("paired_wrong_nested_brackets") +{ + REQUIRE(!matching_brackets::check("[({]})")); +} + +TEST_CASE("math_expression") +{ + REQUIRE(matching_brackets::check("(((185 + 223.85) * 15) - 543)/2")); +} + +TEST_CASE("complex_latex_expression") +{ + REQUIRE(matching_brackets::check("\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)")); +} +#endif diff --git a/exercises/bracket-push/test/catch.hpp b/exercises/matching-brackets/test/catch.hpp similarity index 100% rename from exercises/bracket-push/test/catch.hpp rename to exercises/matching-brackets/test/catch.hpp diff --git a/exercises/bracket-push/test/tests-main.cpp b/exercises/matching-brackets/test/tests-main.cpp similarity index 100% rename from exercises/bracket-push/test/tests-main.cpp rename to exercises/matching-brackets/test/tests-main.cpp