Skip to content

Commit

Permalink
matching-brackets: Sync tests (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasxatzial authored Jun 20, 2024
1 parent 8977040 commit 9187c2a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 26 deletions.
22 changes: 19 additions & 3 deletions exercises/practice/matching-brackets/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[81ec11da-38dd-442a-bcf9-3de7754609a5]
description = "paired square brackets"
Expand Down Expand Up @@ -41,12 +48,21 @@ description = "unpaired and nested brackets"
[a0205e34-c2ac-49e6-a88a-899508d7d68e]
description = "paired and wrong nested brackets"

[1d5c093f-fc84-41fb-8c2a-e052f9581602]
description = "paired and wrong nested brackets but innermost are correct"

[ef47c21b-bcfd-4998-844c-7ad5daad90a8]
description = "paired and incomplete brackets"

[a4675a40-a8be-4fc2-bc47-2a282ce6edbe]
description = "too many closing brackets"

[a345a753-d889-4b7e-99ae-34ac85910d1a]
description = "early unexpected brackets"

[21f81d61-1608-465a-b850-baa44c5def83]
description = "early mismatched brackets"

[99255f93-261b-4435-a352-02bdecc9bdf2]
description = "math expression"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,83 @@
(ns matching-brackets-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest testing is]]
matching-brackets))

(deftest paired-square
(is (matching-brackets/valid? "[]") "paired square brackets"))
(deftest paired-square-brackets
(testing "paired square brackets"
(is (matching-brackets/valid? "[]"))))

(deftest empty-string
(is (matching-brackets/valid? "") "empty string"))
(testing "Empty string"
(is (matching-brackets/valid? ""))))

(deftest unpaired-brackets
(is (false? (matching-brackets/valid? "[[")) "unpaired brackets"))
(testing "Unpaired brackets"
(is (false? (matching-brackets/valid? "[[")))))

(deftest wrong-ordered-brackets
(is (false? (matching-brackets/valid? "}{")) "wrong ordered brackets"))
(testing "Wrong ordered brackets"
(is (false? (matching-brackets/valid? "}{")))))

(deftest wrong-closing-bracket
(testing "Wrong closing bracket"
(is (false? (matching-brackets/valid? "{]")))))

(deftest paired-with-whitespace
(is (matching-brackets/valid? "{ }") "paired with whitespace"))
(testing "Paired with whitespace"
(is (matching-brackets/valid? "{ }"))))

(deftest partially-paired-brackets
(testing "Partially paired brackets"
(is (false? (matching-brackets/valid? "{[])")))))

(deftest simple-nested-brackets
(is (matching-brackets/valid? "{[]}")
"simple nested brackets"))
(testing "Simple nested brackets"
(is (matching-brackets/valid? "{[]}"))))

(deftest several-paired-brackets
(is (matching-brackets/valid? "{}[]")
"several paired brackets"))
(testing "Several paired brackets"
(is (matching-brackets/valid? "{}[]"))))

(deftest paired-and-nested-brackets
(is (matching-brackets/valid? "([{}({}[])])")
"paired and nested brackets"))
(testing "Paired and nested brackets"
(is (matching-brackets/valid? "([{}({}[])])"))))

(deftest unopened-closing-brackets
(is (false? (matching-brackets/valid? "{[)][]}"))
"unopened closing brackets"))
(testing "Unopened closing brackets"
(is (false? (matching-brackets/valid? "{[)][]}")))))

(deftest unpaired-and-nested-brackets
(is (false? (matching-brackets/valid? "([{])"))
"unpaired and nested brackets"))
(testing "Unpaired and nested brackets"
(is (false? (matching-brackets/valid? "([{])")))))

(deftest paired-and-wrong-nested-brackets
(is (false? (matching-brackets/valid? "[({]})"))
"paired and wrong nested brackets"))
(testing "Paired and wrong nested brackets"
(is (false? (matching-brackets/valid? "[({]})")))))

(deftest paired-and-wrong-nested-brackets-but-innermost-are-correct
(testing "Paired and wrong nested brackets but innermost are correct"
(is (false? (matching-brackets/valid? "[({}])")))))

(deftest paired-and-incomplete-brackets
(testing "Paired and incomplete brackets"
(is (false? (matching-brackets/valid? "{}[")))))

(deftest too-many-closing-brackets
(testing "Too many closing brackets"
(is (false? (matching-brackets/valid? "[]]")))))

(deftest early-unexpected-brackets
(testing "Early unexpected brackets"
(is (false? (matching-brackets/valid? ")()")))))

(deftest early-mismatched-brackets
(testing "Early mismatched brackets"
(is (false? (matching-brackets/valid? "{)()")))))

(deftest math-expression
(is (matching-brackets/valid? "(((185 + 223.85) * 15) - 543)/2")
"math expression"))
(testing "Math expression"
(is (matching-brackets/valid? "(((185 + 223.85) * 15) - 543)/2"))))

(deftest complex-latex-expression
(is (matching-brackets/valid? "\\\\left(\\\\begin{array}{cc} \\\\frac{1}{3} & x\\\\\\\\ \\\\mathrm{e}^{x} &... x^2 \\\\end{array}\\\\right)")
"complex latex expression"))
(testing "Complex latex expression"
(is (matching-brackets/valid? "\\\\left(\\\\begin{array}{cc} \\\\frac{1}{3} & x\\\\\\\\ \\\\mathrm{e}^{x} &... x^2 \\\\end{array}\\\\right)"))))

0 comments on commit 9187c2a

Please sign in to comment.