Skip to content

Commit

Permalink
Rename bracket-push exercise (#284)
Browse files Browse the repository at this point in the history
* Rename bracket-push exercise

* Filtering out deleted exercises from the PR diff filter.
  • Loading branch information
smuroff authored and arcuru committed Jun 1, 2019
1 parent 1f40622 commit d4facc8
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion bin/check-exercises.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
]
},
{
"slug": "bracket-push",
"slug": "matching-brackets",
"uuid": "4a517292-3472-40f2-b4b8-5c8c25219ea5",
"core": false,
"unlocked_by": "pangram",
Expand Down
74 changes: 0 additions & 74 deletions exercises/bracket-push/bracket_push_test.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions exercises/bracket-push/example.h

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "bracket_push.h"
#include "matching_brackets.h"
#include <stack>

using namespace std;

namespace bracket_push {
namespace matching_brackets {

bool check(string const& expression)
{
Expand Down
13 changes: 13 additions & 0 deletions exercises/matching-brackets/example.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#if !defined(MATCHING_BRACKETS_H)
#define MATCHING_BRACKETS_H

#include <string>

namespace matching_brackets
{

bool check(std::string const& expression);

}

#endif
74 changes: 74 additions & 0 deletions exercises/matching-brackets/matching_brackets_test.cpp
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.

0 comments on commit d4facc8

Please sign in to comment.