-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
matching-brackets: Sync tests (#645)
- Loading branch information
1 parent
8977040
commit 9187c2a
Showing
2 changed files
with
75 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 56 additions & 23 deletions
79
exercises/practice/matching-brackets/test/matching_brackets_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)")))) |